ski900

StudentTranscript

Jun 8th, 2013
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace AcademicTranscript
  9. {
  10.     class Student
  11.     {
  12.         private string studentName;
  13.         private int studentID;
  14.  
  15.         public string getName { get { return studentName; } }
  16.         public int getID { get { return studentID; } }
  17.  
  18.         public Student (String sName, int sID)
  19.         {
  20.             studentName = sName;
  21.             studentID = sID;
  22.         }
  23.  
  24.         public void setName(string name)
  25.         {
  26.             if (name == null)
  27.             {
  28.                 return;
  29.             }
  30.  
  31.             studentName = name;
  32.         }
  33.  
  34.         public void setID(int id)
  35.         {
  36.             if (id == null)
  37.             {
  38.                 return;
  39.             }
  40.  
  41.             studentID = id;
  42.         }
  43.        
  44.         public void PrintStudent()
  45.         {
  46.              Console.WriteLine("Student Name: {0}\nStudent ID: {1}", getName, getID);
  47.         }
  48.     }
  49.  
  50.     class Course
  51.     {
  52.         private string course;
  53.         private int credits;
  54.         private double grade;
  55.         private double[] gpa;
  56.  
  57.         public string getCourse { get { return course; } }
  58.         public int getCredits { get { return credits; } }
  59.         public double getGrade { get { return grade; } }
  60.  
  61.         public Course(String crse, int crd, double grd)
  62.         {
  63.             course = crse;
  64.             credits = crd;
  65.             grade = grd;
  66.         }
  67.  
  68.         public void setCourse(string courses)
  69.         {
  70.             if (course == null)
  71.             {
  72.                 return;
  73.             }
  74.  
  75.             course = courses;
  76.         }
  77.  
  78.         public void setCredits(int cred)
  79.         {
  80.             if (cred == null)
  81.             {
  82.                 return;
  83.             }
  84.  
  85.             credits = cred;
  86.         }
  87.  
  88.         public void setGrade(double grades)
  89.         {
  90.             if (grades == null)
  91.             {
  92.                 return;
  93.             }
  94.  
  95.             grade = grades;
  96.         }
  97.  
  98.         public void PrintCourses()
  99.         {
  100.             Console.WriteLine("Course: {0}\tCredits: {1} Grade: {2}", getCourse, getCredits, getGrade);
  101.         }
  102.     }
  103.  
  104.     class Quarter
  105.     {
  106.         private string quarter;
  107.         private int year;
  108.  
  109.         public string getQuarter { get { return quarter; } }
  110.         public int getYear { get { return year; } }
  111.  
  112.         public Quarter(String qtrs, int yrs)
  113.         {
  114.             quarter = qtrs;
  115.             year = yrs;
  116.         }
  117.  
  118.         public void PrintQuarter()
  119.         {
  120.             Console.WriteLine("Quarter: {0} of {1}", getQuarter, getYear);
  121.         }
  122.     }
  123.  
  124.     class Transcript
  125.     {
  126.         private Student[] studentArr;
  127.         private Quarter[] quarterArr;
  128.         private Course[] coursesArr;
  129.         private int studentCount;
  130.         private int quarterCount;
  131.         private int courseCount;
  132.  
  133.         public Transcript(int maxLength)
  134.         {
  135.             studentArr = new Student[maxLength];
  136.             quarterArr = new Quarter[maxLength];
  137.             coursesArr = new Course[maxLength];
  138.             studentCount = 0;
  139.             quarterCount = 0;
  140.             courseCount = 0;
  141.         }
  142.  
  143.         public void AddStudent(Student students)
  144.         {
  145.             studentArr[studentCount] = students;
  146.             studentCount++;
  147.         }
  148.  
  149.         public void AddQuarter(Quarter quarters)
  150.         {
  151.             quarterArr[quarterCount] = quarters;            
  152.             quarterCount++;            
  153.         }
  154.  
  155.         public void AddCourse(Course courses)
  156.         {
  157.             coursesArr[courseCount] = courses;
  158.             courseCount++;
  159.         }
  160.  
  161.         public void PrintTranscript()
  162.         {
  163.             for (int i = 0; i < studentCount; i++)
  164.             {
  165.                 studentArr[i].PrintStudent();
  166.             }
  167.             Console.WriteLine();
  168.             for (int j = 0; j < quarterCount; j++)
  169.             {
  170.                 quarterArr[j].PrintQuarter();
  171.                 Console.WriteLine();
  172.                 for (int k = 0; k < courseCount; k++)
  173.                 {
  174.                     coursesArr[k].PrintCourses();
  175.                 }
  176.                 Console.WriteLine();
  177.             }
  178.         }
  179.     }
  180.  
  181.     class Program
  182.     {
  183.         static readonly int MAX_RECORDS = 1000;
  184.         static int student_Count;
  185.         static int transcript_Count = 0;
  186.         static int input = 0;
  187.  
  188.         static void Main(string[] args)
  189.         {
  190.             int choice;
  191.             int exitInput;
  192.             string student_Name;
  193.             int student_ID;
  194.             string student_Quarter;
  195.             string student_Course;
  196.             int student_Credits;
  197.             double student_Grade;
  198.  
  199.  
  200.             Transcript transcript = new Transcript(MAX_RECORDS);
  201.             Transcript transcript2 = new Transcript(MAX_RECORDS);
  202.             Transcript[] transcript3 = new Transcript[100];
  203.            
  204.  
  205.             string header = String.Format("\t\t\tCascadia Community College  \n\t\t\tStudent Academic Transcript \n"
  206.                 + "\t\t\t---------------------------" + Environment.NewLine);
  207.  
  208.             transcript.AddStudent(new Student("Leif Svensson", 960019422));
  209.             transcript.AddQuarter(new Quarter("Fall", 2012));
  210.             transcript.AddCourse(new Course("Math 151", 5, 3.9));
  211.             transcript.AddCourse(new Course("Phys 221", 5, 3.7));
  212.             transcript.AddCourse(new Course("Econ 201", 5, 4.0));
  213.  
  214.             transcript2.AddQuarter(new Quarter("Winter", 2013));
  215.             transcript2.AddCourse(new Course("Math 152", 5, 3.9));
  216.             transcript2.AddCourse(new Course("Phys 222", 5, 3.7));
  217.             transcript2.AddCourse(new Course("BIT  143", 5, 4.0));
  218.            
  219.             Console.WriteLine(header);
  220.             transcript.PrintTranscript();
  221.             transcript2.PrintTranscript();
  222.  
  223.  
  224.             do
  225.             {
  226.                 Console.Clear();
  227.                 Console.WriteLine(header);
  228.                 Console.WriteLine(Environment.NewLine + "\t\t\t      ***Main Menu***\n");
  229.                 Console.WriteLine("\n1.) Add a Student");
  230.                 Console.WriteLine("\n2.) Add Quarter To Record");
  231.                 Console.WriteLine("\n3.) Display Transcripts");
  232.                 Console.WriteLine("\n4.) Search By Student ID");
  233.                 Console.WriteLine("\n5.) Exit The Program");
  234.                 Console.Write("\n\nEnter Your Choice: ");
  235.                 choice = Convert.ToInt32(Console.ReadLine());
  236.  
  237.                 switch (choice)
  238.                 {
  239.                     case 1: //Add student record
  240.                         // Add student name / ID. Set to student array. Use student ID to categorize streamwriter array.                        
  241.                         Console.Clear();
  242.                         Console.WriteLine(header);
  243.                         Console.Write("\n\nEnter Name of Student: ");
  244.                         student_Name = Console.ReadLine();
  245.                         Console.Write("Enter Student ID: ");
  246.                         student_ID = Convert.ToInt32(Console.ReadLine());
  247.  
  248.                         transcript3[transcript_Count] = new Transcript(MAX_RECORDS);
  249.                         transcript3[transcript_Count].AddStudent(new Student(student_Name, student_ID));
  250.  
  251.                         /*students[student_Count] = new Student(first_Name, last_Name, student_ID);
  252.                         transcript[transcript_Count] = new Transcript();
  253.  
  254.                         students[student_Count].setName(first_Name, last_Name);
  255.                         students[student_Count].setID(student_ID);
  256.  
  257.                         transcript[transcript_Count].setQuarter(student_Quarter);
  258.                         transcript[transcript_Count].setCourse(student_Course);
  259.                         transcript[transcript_Count].setCredits(student_Credits);
  260.                         transcript[transcript_Count].setGrade(student_Grade);*/
  261.  
  262.                         if (transcript_Count < 99)
  263.                         {                            
  264.                             transcript_Count++;
  265.                         }
  266.                        
  267.                         break;
  268.  
  269.                     case 2: //Update student quarter
  270.                         // Add quarterly information to each student index.                        
  271.                         while (true)
  272.                         {
  273.                             Console.WriteLine("\n\nWould you like to add more courses?\n\nPress '1' for YES\nPress '2' for NO\n");
  274.                             string quartInput = Console.ReadLine();
  275.                             int qInput = Convert.ToInt32(quartInput);
  276.  
  277.                             if (qInput == 1)
  278.                             {
  279.                                 Console.Clear();
  280.                                 Console.Write("Enter a Course: ");
  281.                                 student_Course = Console.ReadLine();
  282.                                 Console.Write("Enter the Amount of Credits: ");
  283.                                 student_Credits = Convert.ToInt32(Console.ReadLine());
  284.                                 Console.Write("Enter Grade: ");
  285.                                 student_Grade = Convert.ToDouble(Console.ReadLine());
  286.  
  287.                                 /*transcript[student_Count].setQuarter(student_Quarter);
  288.                                 transcript[student_Count].setCourse(student_Course);
  289.                                 transcript[student_Count].setCredits(student_Credits);
  290.                                 transcript[student_Count].setGrade(student_Grade);*/
  291.                             }
  292.                             else
  293.                             {
  294.                                 break;
  295.                             }
  296.                         }
  297.  
  298.                         break;
  299.                     case 3: //Display records
  300.                         Console.Clear();
  301.                         Console.WriteLine(header);
  302.                         transcript.PrintTranscript();
  303.                         transcript2.PrintTranscript();
  304.                         break;
  305.                     case 4: //Search by student ID
  306.                         break;
  307.                 }
  308.                 Console.WriteLine("\nWould you like to continue?\n\nPress '1' for YES\nPress '2' for NO" + Environment.NewLine);
  309.                 exitInput = Convert.ToInt32(Console.ReadLine());
  310.             } while (exitInput == 1 || choice != 5);
  311.  
  312.             Console.ReadKey();
  313.         }
  314.     }
  315. }
Advertisement
Add Comment
Please, Sign In to add comment