Facebook
From Tan Jun QI, 4 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 47
  1. /**
  2.  * Author: Tan Jun Qi
  3.  * Student ID: 33872846
  4.  * Unit: ICT 167 Principles of computer Science
  5.  * Lecturer: Aaron Yeo
  6.  *
  7.  */
  8. public class Postgraduate extends Student {
  9.     int assignment;
  10.     int presentation;
  11.     int exam;
  12.     double overallmark;
  13.  
  14.    
  15.  
  16.     public Postgraduate(String type,String title,String firstname,String lastname,long StuID,int day,int month,int year,
  17.             int assignment, int presentation, int exam) {
  18.         super(type,title, firstname, lastname, StuID, day, month, year);
  19.         this.assignment = assignment;
  20.         this.presentation = presentation;
  21.         this.exam = exam;
  22.         Overallmark();
  23.     }
  24.    
  25.     public void Overallmark() // overide from super class
  26.     {
  27.         double totala = assignment*0.3; // times 30%
  28.         double present = presentation*0.2; //time 20%
  29.         double texam = exam*0.5; // times 50%
  30.         double total = totala+present+texam; // add together
  31.         overallmark = total;
  32.        
  33.     }
  34.    
  35.     public double getOverallmark()
  36.     {
  37.         return overallmark; // overide from super clasee
  38.     }
  39.    
  40.    
  41.     public void print()
  42.     {
  43.         super.print();
  44.        
  45.         super.grade(overallmark);
  46.         System.out.println("The assignment mark is "+assignment);
  47.         System.out.println("The presentation is "+presentation);
  48.         System.out.println("The exam mark is "+exam);
  49.         System.out.printf("The overallmark is %.2f\ngS",overallmark);
  50.         System.out.println("The grade is "+grade);
  51.     }
  52.  
  53.    
  54.    
  55.     public int getAssignment() {
  56.         return assignment;
  57.     }
  58.  
  59.     public void setAssignment(int assignment) {
  60.         this.assignment = assignment;
  61.     }
  62.  
  63.     public int getPresentation() {
  64.         return presentation;
  65.     }
  66.  
  67.     public void setPresentation(int presentation) {
  68.         this.presentation = presentation;
  69.     }
  70.  
  71.     public int getExam() {
  72.         return exam;
  73.     }
  74.  
  75.     public void setExam(int exam) {
  76.         this.exam = exam;
  77.     }
  78.    
  79.    
  80. }
  81.  
  82.  
  83.  
  84.  
  85. /**
  86.  *Author: Tan Jun Qi
  87.  * Student ID: 33872846
  88.  * Unit: ICT 167 Principles of computer Science
  89.  * Lecturer: Aaron Yeo
  90.  *
  91.  */
  92.  
  93. public class UndergradeStudent extends Student{
  94.     int assignment1;
  95.     int assignment2;
  96.     int assignment3;
  97.     int practical;
  98.     int exam;
  99.     double overallmark;
  100.  
  101.     public UndergradeStudent(String type, String title,String firstname, String lastname,long stuID,int day, int month,
  102.             int year,int assignment1, int assignment2, int assignment3,int practical, int exam) {
  103.        
  104.         super(type, title, firstname,lastname,stuID, day, month, year);
  105.         this.assignment1 = assignment1;
  106.         this.assignment2 = assignment2;
  107.         this.assignment3 = assignment3;
  108.         this.practical = practical;
  109.         this.exam = exam;
  110.         Overallmark(); // calculate marks when object created
  111.     }
  112.    
  113.     public UndergradeStudent()
  114.     {
  115.        
  116.     }
  117.    
  118.    
  119.    
  120.     public void Overallmark()
  121.     { // overide from super class
  122.         double ass1 = assignment1*0.15; // 15%
  123.         double ass2 = assignment2*0.15;//15%
  124.         double ass3 = assignment3*0.15;//15%
  125.         double exam1 = exam*0.45;//45*
  126.         double prac = practical*0.1;//10%
  127.         double overallmark = ass1+ass2+ass3+exam1+prac; // adding them up
  128.         this.overallmark = overallmark; // assigned to instance variable
  129.                
  130.        
  131.        
  132.        
  133.        
  134.     }
  135.  
  136.     public double getOverallmark() {
  137.          //overide from super class
  138.         return overallmark;
  139.     }
  140.  
  141.    
  142.    
  143.    
  144.    
  145.     public void print()
  146.     {
  147.         super.print();
  148.         super.grade(overallmark);
  149.         System.out.println("The mark for assignment 1 is "+assignment1);
  150.         System.out.println("The mark for assignment 2 is "+assignment2);
  151.         System.out.println("The mark for assignment 3 is "+assignment3);
  152.         System.out.println("The mark for practical is "+practical);
  153.         System.out.println("The mark for exam is "+exam);
  154.         System.out.printf("The overallmark is %.2f\n",overallmark);
  155.         System.out.println("The grade is "+grade);
  156.     }
  157.    
  158.     public int getAssignemnt1() {
  159.         return assignment1;
  160.     }
  161.  
  162.     public void setAssignemnt1(int assignemnt1) {
  163.         this.assignment1 = assignemnt1;
  164.     }
  165.  
  166.     public int getAssignment2() {
  167.         return assignment2;
  168.     }
  169.  
  170.     public void setAssignment2(int assignment2) {
  171.         this.assignment2 = assignment2;
  172.     }
  173.  
  174.     public int getAssignment3() {
  175.         return assignment3;
  176.     }
  177.  
  178.     public void setAssignment3(int assignment3) {
  179.         this.assignment3 = assignment3;
  180.     }
  181.  
  182.     public int getPractical() {
  183.         return practical;
  184.     }
  185.  
  186.     public void setPractical(int practical) {
  187.         this.practical = practical;
  188.     }
  189.  
  190.     public int getExam() {
  191.         return exam;
  192.     }
  193.  
  194.     public void setExam(int exam) {
  195.         this.exam = exam;
  196.     }
  197.    
  198. }
  199.  
  200.  
  201.  
  202. import java.util.*;
  203.  
  204.  
  205. /**
  206.  * Author: Tan Jun Qi
  207.  * Student ID: 33872846
  208.  * Unit: ICT 167 Principles of computer Science
  209.  * Lecturer: Aaron Yeo
  210.  */
  211.  
  212. public class Student  {
  213.     String title;
  214.     String firstname;
  215.     String lastname;
  216.     long stuID;
  217.     int year;
  218.     int month;
  219.     int day;
  220.     String grade;
  221.     String type;
  222.    
  223.  
  224.    
  225.    
  226.    
  227.     public Student (String type, String title,String firstname, String lastname,long stuID,int day, int month, int year)
  228.     { // Constructor used to create student object
  229.         this.title = title;
  230.         this.firstname = firstname;
  231.         this.lastname = lastname;
  232.         this.stuID = stuID;
  233.         this.year = year;
  234.         this.month=month;
  235.         this.day=day;
  236.         this.type = type;
  237.        
  238.     }
  239.     public Student()
  240.     {
  241.        
  242.     }
  243.  
  244.     public String getType() {
  245.         return type;
  246.     }
  247.    
  248.     public void Overallmark() // it would polymorph into either Undergrad or student if its empty
  249.     {
  250.        
  251.     }
  252.    
  253.    
  254.    
  255.    
  256.    
  257.     public void grade(double overallmark)
  258.     { // assignning grade t0 parameter overallmark
  259.         if(overallmark>=80)
  260.         {
  261.             grade = "HD";
  262.         }
  263.         else if(overallmark>=70)
  264.         {
  265.             grade = "D";
  266.         }
  267.         else if(overallmark>=60)
  268.         {
  269.             grade = "C";
  270.         }
  271.         else if (overallmark>=50)
  272.         {
  273.             grade = "P";
  274.         }
  275.         else if (overallmark<50)
  276.         {
  277.             grade = "N";
  278.         }  
  279.     }
  280.    
  281.    
  282.     public boolean equals(Student s1, Student s2)
  283.     {
  284.         boolean equals = false;
  285.        
  286.         if(s1.getStuID()==s2.getStuID())
  287.         {
  288.             equals = true;
  289.         }
  290.        
  291.         return equals;
  292.                
  293.                
  294.     }
  295.    
  296.     public void sort(ArrayList<Student> stu)
  297.     {
  298.        
  299.         boolean swap = true;
  300.         while(swap)
  301.         {
  302.         swap = false;
  303.         for(int i =1;i<stu.size();i++)
  304.         {
  305.             Student second = stu.get(i); // assigning index 1 student into student variable second
  306.             Student first = stu.get(i-1); // assigning index 0 student into student variable first
  307.            
  308.                 if(second.getStuID()<first.getStuID())
  309.                 {
  310.                     stu.set(i,first); // swap index 1 with index 0
  311.                     stu.set(i-1, second); // swap index 0 to index 1
  312.                     swap = true;
  313.                 }
  314.            
  315.         }
  316.        
  317.         }
  318.        
  319.     }
  320.    
  321.     public void print()
  322.     {
  323.         System.out.println(type);
  324.         System.out.println("The Salutation is "+title);
  325.         System.out.println("The first name is "+firstname);
  326.         System.out.println("the last name is "+lastname);
  327.         System.out.println("The student ID is "+stuID);
  328.         System.out.println("The day of birth is "+day);
  329.         System.out.println("The month of birth is "+month);
  330.         System.out.println("The year of birth is "+year);
  331.        
  332.        
  333.     }
  334.  
  335.     public String getTitle() {
  336.         return title;
  337.     }
  338.  
  339.     public void setTitle(String title) {
  340.         this.title = title;
  341.     }
  342.  
  343.     public String getFirstname() {
  344.         return firstname;
  345.     }
  346.  
  347.     public void setFirstname(String firstname) {
  348.         this.firstname = firstname;
  349.     }
  350.  
  351.     public String getLastname() {
  352.         return lastname;
  353.     }
  354.  
  355.     public void setLastname(String lastname) {
  356.         this.lastname = lastname;
  357.     }
  358.  
  359.     public long getStuID() {
  360.         return stuID;
  361.     }
  362.  
  363.     public void setStuID(int stuID) {
  364.         this.stuID = stuID;
  365.     }
  366.  
  367.    
  368.    
  369.    
  370.    
  371.     public double getOverallmark()
  372.     {
  373.         return 0; // it would polymorph to under grade or post graduate
  374.     }
  375.    
  376.  
  377.     public String getGrade() {
  378.         return grade;
  379.     }
  380.  
  381.     public void setGrade(String grade) {
  382.         this.grade = grade;
  383.     }
  384. }
  385.  
  386.  
  387. /*
  388.  * Author: Tan Jun Qi
  389.  * Student ID: 33872846
  390.  * Unit: ICT 167 Principles of computer Science
  391.  * Lecturer: Aaron Yeo
  392.  */
  393.  
  394. /**
  395.  *
  396.  * @author mega-
  397.  */
  398. public class StudentTest  {
  399.     public static void main(String [] args)
  400.     {
  401.         Scanner read = new Scanner(System.in);
  402.         int undercount = 0;
  403.         int postcount = 0;
  404.         int addchoice = 0;
  405.         double Uavg=0;
  406.         double Pavg=0;
  407.        
  408.         System.out.println("Type 1 for UnderGrad and 2 for PostGrad");
  409.         int choice = read.nextInt(); // reading if it 1 or 2
  410.         read.nextLine();
  411.         while(choice!=1 && choice!=2) // if choice not 1 and not 2
  412.         {
  413.             System.out.println("Invalid choice, please re-enter your choice again");
  414.             choice = read.nextInt(); // prompt again
  415.            
  416.         }
  417.        
  418.         ArrayList<Student> Ustu = new ArrayList<Student>(); // create arraylist of student object
  419.         // Reading the file to the arraylist
  420.             try{
  421.             String fileName = "student.txt";
  422.             File file = new File(fileName); // create a new file
  423.             Scanner inputstream = new Scanner(file);// ready to read from the new created file
  424.            
  425.             while(inputstream.hasNextLine())//whille there is next line of records
  426.             {
  427.             String line = inputstream.nextLine(); // read the line of record  
  428.             String [] linearray = line.split(","); // Store the individual data from file seperated by commas.
  429.             String status = linearray[0]; // Determining if the student is recorded as post or under.
  430.             String title = linearray[1];
  431.             String firstname = linearray[2];
  432.             String lastname = linearray[3];
  433.             long Stuid = Long.parseLong(linearray[4]);
  434.             int day = Integer.parseInt(linearray[5]);
  435.             int month = Integer.parseInt(linearray[6]);
  436.             int year = Integer.parseInt(linearray[7]);
  437.             if(status.equals("Under"))
  438.             {
  439.             int ass1 = Integer.parseInt(linearray[8]);
  440.             int ass2 = Integer.parseInt(linearray[9]);
  441.             int ass3 = Integer.parseInt(linearray[10]);
  442.             int prac = Integer.parseInt(linearray[11]);
  443.             int exam = Integer.parseInt(linearray[12]);
  444.             Ustu.add (new UndergradeStudent(status,title,firstname,lastname,Stuid,day,month,
  445.             year,ass1,ass2,ass3,prac,exam)); // creating object undergradestudent with the constructor and store in arraylist
  446.             undercount++;
  447.             }
  448.             else if(status.equals("Graduate"))
  449.             {
  450.             int assignment = Integer.parseInt(linearray[8]);
  451.             int presentation = Integer.parseInt(linearray[9]);
  452.             int exam = Integer.parseInt(linearray[10]);
  453.                 Ustu.add(new Postgraduate(status,title,firstname,lastname,Stuid,day,month
  454.                 ,year,assignment,presentation,exam)); // creating object postgraduate and store in arraylist
  455.             postcount++;
  456.             }
  457.             }
  458.                  
  459.             }
  460.             catch (FileNotFoundException e) // if file cannot be found
  461.                     {
  462.                         System.out.println("File not found");
  463.                        
  464.                        
  465.                     }
  466.             while(addchoice!=1)
  467.             {
  468.             System.out.println("");
  469.             Menu(); // show the menu from the method
  470.             addchoice=read.nextInt(); // prompt for the method choice
  471.             read.nextLine(); // cleaning the scanner
  472.             switch(addchoice)
  473.             {
  474.                 case 1:
  475.                         {
  476.                             System.out.println("-----------Exit system--------/");
  477.                              break;  
  478.                         }
  479.                 case 2:
  480.                         {
  481.                             Addstudent(addchoice,choice,Ustu); // call from method to add student manually or from file
  482.                             break;
  483.                    
  484.                         }
  485.                 case 3:
  486.                         {
  487.                             for(Student s: Ustu)
  488.                             { // loop all student in arraylist
  489.                                 s.print(); // print all object in arraylist
  490.                                 System.out.println("");
  491.                             }
  492.                             break;
  493.                    
  494.                         }
  495.                 case 4:
  496.                         {
  497.                             double sum=0;
  498.                             double sum1=0;
  499.                             double avg=0;
  500.                             double avg1=0;
  501.                             int ucount=0;
  502.                             int gcount=0;
  503.                             for(int i = 0;i<Ustu.size();i++)
  504.                               {
  505.                                 if(Ustu.get(i) instanceof UndergradeStudent)
  506.                                  { // if arraylist index is an object of undergrad student
  507.                                     sum += Ustu.get(i).getOverallmark(); // get the overallmark of the student
  508.                                     ucount++; // count how many undergrad student
  509.                
  510.                                  }
  511.                             else if(Ustu.get(i) instanceof Postgraduate)
  512.                             {
  513.                                 sum1+=Ustu.get(i).getOverallmark();
  514.                                 gcount++;
  515.                             }
  516.                                  
  517.                              }
  518.                             // total overallmark of post/undergrad divide by total number of undergrade student or poststudent
  519.                             avg = sum/ucount;
  520.                             avg1 = sum1/gcount;
  521.                             System.out.println("The overallmark for undergrad student is "
  522.                                      +avg+" and post graduate is "+avg1);
  523.                             Uavg = avg;
  524.                             Pavg = avg1;
  525.                             break;
  526.                               }
  527.                        
  528.                 case 5:
  529.                    
  530.                             {
  531.                                int Ucount=0;
  532.                                int Pcount=0;
  533.                                double track=0;
  534.                                 for (int i = 0;i<Ustu.size();i++)
  535.                                 {
  536.                                     if(Ustu.get(i) instanceof UndergradeStudent)
  537.                                     {// instance of = Ustu.get(i).gettype.equals("Under);
  538.                                         track = Ustu.get(i).getOverallmark();
  539.                                         // getting overallmark of student
  540.                                         if(track>=Uavg)
  541.                                         { // if less than total overall marks
  542.                                            Ucount++;  // count student
  543.                                         }
  544.                                     }
  545.                                     else if(Ustu.get(i) instanceof Postgraduate)
  546.                                     {
  547.                                         track = Ustu.get(i).getOverallmark();
  548.                                         if(track>=Pavg)
  549.                                         {
  550.                                             Pcount++;
  551.                                         }
  552.                                     }
  553.                                    
  554.                                 }
  555.                                 System.out.println("The number of undergraduate student that has more than the overallmark is "
  556.                                         +Ucount+ "and Postgraduate is "+Pcount);
  557.                                 break;
  558.                    
  559.                             }
  560.                            
  561.                 case 6:
  562.                             {
  563.                                 boolean found = false;
  564.                                 System.out.println("Please enter the student ID to search");
  565.                                 long search = read.nextLong();
  566.                                 for(int i = 0;i<Ustu.size();i++)
  567.                                 {
  568.                                     if(search==Ustu.get(i).stuID)
  569.                                     { // search for  student ID
  570.                                         System.out.println("");
  571.                                         Ustu.get(i).print(); // print if search id found student id
  572.                                         found=true;
  573.                                     }
  574.                                 }
  575.                                 if(found == false)
  576.                                 {
  577.                                     System.out.println("");
  578.                                     System.out.println("No student found with the Student ID");
  579.                                 }
  580.                                 break;
  581.                                    
  582.                    
  583.                             }
  584.                 case 7:
  585.                             {
  586.                                 boolean found = false;
  587.                                 System.out.println("Please enter the first name ");
  588.                                 String fname = read.nextLine();
  589.                                 System.out.println("please enter the last name");
  590.                                 String lname = read.nextLine();
  591.                                 for(int i = 0;i<Ustu.size();i++)
  592.                                 {
  593.                                     if(fname.equalsIgnoreCase(Ustu.get(i).firstname) && lname.equalsIgnoreCase(Ustu.get(i).lastname))
  594.                                     { // if user input firstname and last name match with arraylist index
  595.                                         System.out.println("");
  596.                                         Ustu.get(i).print(); // print arraylist index
  597.                                         found=true;
  598.                                     }
  599.                                 }
  600.                                 if(found == false)
  601.                                 {
  602.                                     System.out.println(" ");
  603.                                     System.out.println("Student data not found");
  604.                                 }
  605.                                 break;
  606.                                
  607.                              
  608.                             }
  609.                 case 8:            
  610.                             {
  611.                                
  612.                                Student s = Ustu.get(0); // assigning arraylist index 0 to student type s
  613.                                s.sort(Ustu); // sorting the array list
  614.                                for(Student c:Ustu)
  615.                                {
  616.                                    c.print(); // print out the sorted array list
  617.                                }
  618.                                break;
  619.                                
  620.                             }
  621.                 case 9:
  622.                             {
  623.                                 String file = "Sorted.CSV"; // create csv file name
  624.                                 try{
  625.                                 PrintWriter OutputStream = null;
  626.                                 OutputStream = new PrintWriter(file);
  627.                                 OutputStream.println("StudentID"+","+"First name"+","+"Last name"+","+"day of birth"+","
  628.                                         + "Month of birth"+","+"Year of birth"+","+"Grade"+","+"Overallmark"); // set the title for the csv record
  629.                                 for(Student s:Ustu)
  630.                                 {
  631.                                     OutputStream.println(s.stuID+","+s.firstname+","+s.lastname+","+s.day+","+s.month+","+s.year+","
  632.                                     +s.grade+","+s.getOverallmark()); // print out all of the details of the array list
  633.                                 }
  634.                                     System.out.println("data recorded to sorted.CSV file"); // print if all successfully converted
  635.                                 OutputStream.close(); // close to save
  636.                                 }
  637.                                 catch(FileNotFoundException e) // if file cannot be found print and exit system
  638.                                         {
  639.                                             System.out.println("File not found ");
  640.                                             System.exit(0);
  641.                                         }
  642.                                
  643.                    
  644.                             }
  645.             }
  646.                        
  647.                        
  648.                          
  649.            
  650.         }
  651.     }
  652.    
  653.                    
  654.                    
  655.                    
  656.            
  657.            
  658.            
  659.    public static void Menu()
  660.     {
  661.             System.out.println("Type in the numbers to commence the action");
  662.             System.out.println("1. Quit");
  663.             System.out.println("2. Add");
  664.             System.out.println("3. Output");
  665.             System.out.println("4. Compute");
  666.             System.out.println("5. Determine and display");
  667.             System.out.println("6. Student ID");
  668.             System.out.println("7. Student name");
  669.             System.out.println("8. Sort ");
  670.             System.out.println("9. Print");
  671.            
  672.     }
  673.    public static void Addstudent( int choice, int type, ArrayList<Student> stu)
  674.    {
  675.        Scanner read = new Scanner(System.in);
  676.        System.out.println("Do you want to read from another file (yes or no)");
  677.        String addchoice = read.nextLine();
  678.        if(addchoice.equalsIgnoreCase("yes"))
  679.        {
  680.            System.out.println("please enter the file name to enter");
  681.            String filename = read.nextLine();
  682.            File file1 = new File(filename);
  683.            try{
  684.            Scanner inputstream = new Scanner(file1);
  685.            while(inputstream.hasNextLine())
  686.            {
  687.             String line = inputstream.nextLine(); // read the line of record  
  688.             String [] linearray = line.split(","); // Store the individual data from file seperated by commas.
  689.             String status = linearray[0]; // Determining if the student is recorded as post or under.
  690.             String title = linearray[1];
  691.             String firstname = linearray[2];
  692.             String lastname = linearray[3];
  693.             long Stuid = Long.parseLong(linearray[4]);
  694.             int day = Integer.parseInt(linearray[5]);
  695.             int month = Integer.parseInt(linearray[6]);
  696.             int year = Integer.parseInt(linearray[7]);
  697.             if(status.equals("Under"))
  698.             {
  699.             int ass1 = Integer.parseInt(linearray[8]);
  700.             int ass2 = Integer.parseInt(linearray[9]);
  701.             int ass3 = Integer.parseInt(linearray[10]);
  702.             int prac = Integer.parseInt(linearray[11]);
  703.             int exam = Integer.parseInt(linearray[12]);
  704.             stu.add (new UndergradeStudent(status,title,firstname,lastname,Stuid,day,month,
  705.             year,ass1,ass2,ass3,prac,exam));
  706.            
  707.             }
  708.             else if(status.equals("Graduate"))
  709.             {
  710.             int assignment = Integer.parseInt(linearray[8]);
  711.             int presentation = Integer.parseInt(linearray[9]);
  712.             int exam = Integer.parseInt(linearray[10]);
  713.             stu.add(new Postgraduate(status,title,firstname,lastname,Stuid,day,month
  714.                 ,year,assignment,presentation,exam));
  715.             }
  716.            }
  717.                System.out.println("");
  718.                System.out.println("Record added successfully");
  719.            }
  720.            catch(FileNotFoundException e)
  721.            {
  722.                System.out.println("file not found");
  723.                System.exit(0);
  724.            }
  725.            
  726.        }
  727.        
  728.        System.out.println("Do you want to manually add student? (yes or no)");
  729.        String mchoice = read.nextLine();
  730.        
  731.        if(mchoice.equalsIgnoreCase("yes")&&choice==2 && type ==1)
  732.        {
  733.        System.out.println("Enter how many undergrad students do you want to add?");
  734.        int num = read.nextInt();
  735.        int count = 1;
  736.        read.nextLine();
  737.        while(count<=num)
  738.        {
  739.        String status = "Under";  
  740.        System.out.println("Please enter the Salutation for the new undergrad student");
  741.        String title = read.nextLine();
  742.        System.out.println("Please enter the firstname of the undergrad student");
  743.        String first = read.nextLine();
  744.        System.out.println("Please enter the lastname of the undergrad student");
  745.        String last = read.nextLine();
  746.        System.out.println("Please enter the student ID");
  747.        long ID = read.nextLong();
  748.        read.nextLine();
  749.        System.out.println("Please enter the day of birth");
  750.        int day = read.nextInt();
  751.        read.nextLine();
  752.        System.out.println("Please enter the month of birth");
  753.        int month = read.nextInt();
  754.        read.nextLine();
  755.        System.out.println("Please enter the year of birth");
  756.        int year = read.nextInt();
  757.        read.nextLine();
  758.        System.out.println("Please enter the mark for assignment1");
  759.        int ass1 = read.nextInt();
  760.        read.nextLine();
  761.        System.out.println("please enter the mark for assignment2");
  762.        int ass2 = read.nextInt();
  763.        read.nextLine();
  764.        System.out.println("Please enter the mark for assignment2");
  765.        int ass3 = read.nextInt();
  766.        read.nextLine();
  767.        System.out.println("please enter the mark for practical");
  768.        int prac = read.nextInt();
  769.        read.nextLine();
  770.        System.out.println("Please enter the mark for exam");
  771.        int exam = read.nextInt();
  772.        read.nextLine();
  773.        stu.add(new UndergradeStudent(status,title,first,last,ID,day,month,year,ass1,ass2,ass3,prac,exam));
  774.        count++;
  775.        }
  776.        }
  777.        
  778.        else if (mchoice.equalsIgnoreCase("yes")&&choice==2 && type ==2)
  779.        {
  780.            System.out.println("How many post graduate students do you want to enter?");
  781.            int num2 = read.nextInt();
  782.            int count2 = 1;
  783.            String status = "Graduate";
  784.            while(count2<=num2)
  785.            {
  786.                
  787.        System.out.println("Please enter the Salutation for the new postgraduate student");
  788.        String title = read.nextLine();
  789.        System.out.println("Please enter the firstname of the postgraduate student");
  790.        String first = read.nextLine();
  791.        System.out.println("Please enter the lastname of the postgraduate student");
  792.        String last = read.nextLine();
  793.        System.out.println("Please enter the student ID");
  794.        long ID = read.nextLong();
  795.        read.nextLine();
  796.        System.out.println("Please enter the day of birth");
  797.        int day = read.nextInt();
  798.        read.nextLine();
  799.        System.out.println("Please enter the month of birth");
  800.        int month = read.nextInt();
  801.        read.nextLine();
  802.        System.out.println("Please enter the year of birth");
  803.        int year = read.nextInt();
  804.        read.nextLine();
  805.        System.out.println("Please enter the mark for group assignment");
  806.        int groupass = read.nextInt();
  807.        read.nextLine();
  808.        System.out.println("please enter the mark for group presentation");
  809.        int grouppre = read.nextInt();
  810.        read.nextLine();
  811.        System.out.println("Please enter the mark for exam");
  812.        int exam = read.nextInt();
  813.        stu.add(new Postgraduate(status,title,first,last,ID,day,month,year,groupass,grouppre,exam));
  814.        count2++;
  815.            }
  816.        }
  817.        
  818.    }
  819.    
  820.    
  821.    
  822. }
  823.