From f8965c56d0ab34a73a6e60d16927e4c5923deb3f Mon Sep 17 00:00:00 2001 From: Deshan Date: Mon, 20 May 2019 11:36:23 +0530 Subject: [PATCH] -Initial Commit - Completed Project --- .idea/dictionaries/Deshan.xml | 9 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + Student Grading System.iml | 11 + src/Comparators/FinalMarks.java | 21 + src/Comparators/LastName.java | 21 + src/Enum/Grade.java | 9 + src/GUI/Horizontal_View.java | 64 +++ src/GUI/StarCreation/Horizontal_Star.java | 25 + src/GUI/StarCreation/Vertical_Star.java | 25 + src/GUI/Vertical_View.java | 59 ++ src/StudentClass/Student.java | 106 ++++ src/StudentTester/Test.java | 632 ++++++++++++++++++++++ 14 files changed, 1002 insertions(+) create mode 100644 .idea/dictionaries/Deshan.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Student Grading System.iml create mode 100644 src/Comparators/FinalMarks.java create mode 100644 src/Comparators/LastName.java create mode 100644 src/Enum/Grade.java create mode 100644 src/GUI/Horizontal_View.java create mode 100644 src/GUI/StarCreation/Horizontal_Star.java create mode 100644 src/GUI/StarCreation/Vertical_Star.java create mode 100644 src/GUI/Vertical_View.java create mode 100644 src/StudentClass/Student.java create mode 100644 src/StudentTester/Test.java diff --git a/.idea/dictionaries/Deshan.xml b/.idea/dictionaries/Deshan.xml new file mode 100644 index 0000000..572d3db --- /dev/null +++ b/.idea/dictionaries/Deshan.xml @@ -0,0 +1,9 @@ + + + + dehami + deshan + koswatte + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..248efa1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Student Grading System.iml b/Student Grading System.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Student Grading System.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Comparators/FinalMarks.java b/src/Comparators/FinalMarks.java new file mode 100644 index 0000000..83c22f7 --- /dev/null +++ b/src/Comparators/FinalMarks.java @@ -0,0 +1,21 @@ +package Comparators; + +import StudentClass.*; +import java.util.Comparator; + +/* Comparator added as the Student class does not implement comparable + so to compare a class which does not implement comparable you should + add a comparator*/ + +public class FinalMarks implements Comparator { + + /* An overridden method in the super class Object. + The method has two arguments where two objects + of Student must be given then the method will + compare the final marks of the compared students. + */ + @Override + public int compare (Student o1, Student o2){ + return o1.getFinalMarks() - o2.getFinalMarks(); + } +} diff --git a/src/Comparators/LastName.java b/src/Comparators/LastName.java new file mode 100644 index 0000000..6dc9e24 --- /dev/null +++ b/src/Comparators/LastName.java @@ -0,0 +1,21 @@ +package Comparators; + +import java.util.Comparator; +import StudentClass.*; + +/* Comparator added as the Student class does not implement comparable + so to compare a class which does not implement comparable you should + add a comparator*/ + +public class LastName implements Comparator { + + /* An overridden method in the super class Object. + The method has two arguments where two objects + of Student must be given then the method will + compare the last name of the compared students. + */ + @Override + public int compare (Student o1, Student o2){ + return o1.getlName().compareTo(o2.getlName()); + } +} diff --git a/src/Enum/Grade.java b/src/Enum/Grade.java new file mode 100644 index 0000000..1109d62 --- /dev/null +++ b/src/Enum/Grade.java @@ -0,0 +1,9 @@ +package Enum; + +/* This is an enum which is like our own string + which will only contain the values which are mentioned + below + */ +public enum Grade { + First_Class, Second_Upper_Class, Second_Lower_Class, General_Pass, Fail_Resit, Fail_Retake +} diff --git a/src/GUI/Horizontal_View.java b/src/GUI/Horizontal_View.java new file mode 100644 index 0000000..1c4a538 --- /dev/null +++ b/src/GUI/Horizontal_View.java @@ -0,0 +1,64 @@ +package GUI; + +import GUI.StarCreation.Horizontal_Star; +import StudentClass.Student; +import StudentTester.Test; + +import javax.swing.*; +import java.awt.*; + +public class Horizontal_View extends JFrame { + public Horizontal_View() { + super("Overall Marks in Horizontal Histogram"); + setSize(450, 350); + + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout()); + add(mainPanel); + + JPanel subPanel1 = new JPanel(); + JLabel header = new JLabel("Horizontal Histogram"); + subPanel1.add(header); + mainPanel.add(subPanel1, BorderLayout.PAGE_START); + + JPanel subPanel2 = new JPanel(); + subPanel2.setLayout(new GridLayout(4, 1)); + + JLabel lbl1 = new JLabel(" 0 - 29"); + JLabel lbl2 = new JLabel("30 - 39"); + JLabel lbl3 = new JLabel("40 - 69"); + JLabel lbl4 = new JLabel("70 - 100"); + + subPanel2.add(lbl1); + subPanel2.add(lbl2); + subPanel2.add(lbl3); + subPanel2.add(lbl4); + + mainPanel.add(subPanel2, BorderLayout.LINE_START); + + JPanel subPanel3 = new JPanel(); + subPanel3.setLayout(new GridLayout(4, 1)); + + int num1 = 0; + int num2 = 0; + int num3 = 0; + int num4 = 0; + for (Student student : Test.students) { + if (student.getFinalMarks() < 30) num1++; + else if (student.getFinalMarks() < 40) num2++; + else if (student.getFinalMarks() < 70) num3++; + else num4++; + } + subPanel3.add(new Horizontal_Star(num1));//Adding stars + subPanel3.add(new Horizontal_Star(num2));//Adding stars + subPanel3.add(new Horizontal_Star(num3));//Adding stars + subPanel3.add(new Horizontal_Star(num4));//Adding stars + mainPanel.add(subPanel3, BorderLayout.CENTER); + + JLabel noOfStds = new JLabel("Total number of students : " + Test.students.size()); + mainPanel.add(noOfStds, BorderLayout.PAGE_END); + + setVisible(true); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + } +} diff --git a/src/GUI/StarCreation/Horizontal_Star.java b/src/GUI/StarCreation/Horizontal_Star.java new file mode 100644 index 0000000..33636fc --- /dev/null +++ b/src/GUI/StarCreation/Horizontal_Star.java @@ -0,0 +1,25 @@ +package GUI.StarCreation; + +import javax.swing.*; +import java.awt.*; + +public class Horizontal_Star extends JPanel { + + private int nStars = 0; + + // Overridden paint method to paint our own string + @Override + public void paint(Graphics g) {//Using graphics to display the stars + Graphics2D g2d = (Graphics2D) g; + for (int i = 0; i < nStars; i++) { + g2d.setFont(new Font("TimesRoman", Font.BOLD, 20)); + g2d.setColor(Color.BLACK); + g2d.drawString("*", 20 + (i * 10), 45); + } + } + + // Non Default constructor + public Horizontal_Star(int list) { + this.nStars = list; + } +} diff --git a/src/GUI/StarCreation/Vertical_Star.java b/src/GUI/StarCreation/Vertical_Star.java new file mode 100644 index 0000000..adf79e1 --- /dev/null +++ b/src/GUI/StarCreation/Vertical_Star.java @@ -0,0 +1,25 @@ +package GUI.StarCreation; + +import javax.swing.*; +import java.awt.*; + +public class Vertical_Star extends JPanel { + + private int nStars = 0; + + // Overridden paint method to paint our own string + @Override + public void paint(Graphics g) {//Using graphics to display the stars + Graphics2D g2d = (Graphics2D) g; + for (int i = 0; i < nStars; i++) { + g2d.setFont(new Font("TimesRoman", Font.BOLD, 20)); + g2d.setColor(Color.BLACK); + g2d.drawString("*", 15, 20 + (i * 10)); + } + } + + // Non Default constructor + public Vertical_Star(int list) { + this.nStars = list; + } +} diff --git a/src/GUI/Vertical_View.java b/src/GUI/Vertical_View.java new file mode 100644 index 0000000..f59854a --- /dev/null +++ b/src/GUI/Vertical_View.java @@ -0,0 +1,59 @@ +package GUI; + +import GUI.StarCreation.Vertical_Star; +import StudentClass.Student; +import StudentTester.Test; +import javax.swing.*; +import java.awt.*; + +public class Vertical_View extends JFrame { + public Vertical_View() { + super("Overall Marks in Vertical Histogram"); + setSize(450, 350); + + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout()); + add(mainPanel); + + + JPanel subPanel1 = new JPanel(); + subPanel1.setLayout(new GridLayout(1, 4)); + + JLabel lbl1 = new JLabel(" 0 - 29"); + JLabel lbl2 = new JLabel("30 - 39"); + JLabel lbl3 = new JLabel("40 - 69"); + JLabel lbl4 = new JLabel("70 - 100"); + + subPanel1.add(lbl1); + subPanel1.add(lbl2); + subPanel1.add(lbl3); + subPanel1.add(lbl4); + + mainPanel.add(subPanel1, BorderLayout.PAGE_START); + + JPanel subPanel2 = new JPanel(); + subPanel2.setLayout(new GridLayout(1, 4)); + + int num1 = 0; + int num2 = 0; + int num3 = 0; + int num4 = 0; + for (Student student : Test.students) { + if (student.getFinalMarks() < 30) num1++; + else if (student.getFinalMarks() < 40) num2++; + else if (student.getFinalMarks() < 70) num3++; + else num4++; + } + subPanel2.add(new Vertical_Star(num1));//Adding stars + subPanel2.add(new Vertical_Star(num2));//Adding stars + subPanel2.add(new Vertical_Star(num3));//Adding stars + subPanel2.add(new Vertical_Star(num4));//Adding stars + mainPanel.add(subPanel2, BorderLayout.CENTER); + + JLabel noOfStds = new JLabel("Total number of students : " + Test.students.size()); + mainPanel.add(noOfStds, BorderLayout.PAGE_END); + + setVisible(true); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + } +} diff --git a/src/StudentClass/Student.java b/src/StudentClass/Student.java new file mode 100644 index 0000000..f4d9ee7 --- /dev/null +++ b/src/StudentClass/Student.java @@ -0,0 +1,106 @@ +package StudentClass; + +import Enum.*; +import java.io.Serializable; + +public class Student implements Serializable { + + // Encapsulating data fields so they cannot be accessed directly + private String fName; + private String lName; + private int regNo; + private int ict_01_marks; + private int ict_02_marks; + private int cw_01_marks; + private int cw_02_marks; + private int finalMarks; + private Grade grade; + + // Default Constructor. I have added this cause this improves coding standards + public Student() { + + } + + // Non default constructor + public Student(String fName, String lName, int regNo, int ict_01_marks, + int ict_02_marks, int cw_01_marks, int cw_02_marks) { + this.fName = fName; + this.lName = lName; + this.regNo = regNo; + this.ict_01_marks = ict_01_marks; + this.ict_02_marks = ict_02_marks; + this.cw_01_marks = cw_01_marks; + this.cw_02_marks = cw_02_marks; + this.finalMarks = this.getFinalMarks(); + this.grade = this.getGrade(); + } + + // Getter and Setter methods + public String getfName() { + return fName; + } + + public void setfName(String fName) { + this.fName = fName; + } + + public String getlName() { + return lName; + } + + public void setlName(String lName) { + this.lName = lName; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public int getIct_01_marks() { + return ict_01_marks; + } + + public int getIct_02_marks() { + return ict_02_marks; + } + + public int getCw_01_marks() { + return cw_01_marks; + } + + public int getCw_02_marks() { + return cw_02_marks; + } + + public int getFinalMarks() { + this.finalMarks = (int) Math.round((this.ict_01_marks * 0.2) + + (this.ict_02_marks * 0.2) + (this.cw_01_marks * 0.3) + + (this.cw_02_marks * 0.3)); + return finalMarks; + } + + public Grade getGrade() { + if ((((this.ict_01_marks + this.ict_02_marks) / 2) >= 30) && + this.cw_01_marks >= 30 && this.cw_02_marks >= 30 + && this.finalMarks >= 40) { + if (this.finalMarks >= 70) { + this.grade = Grade.First_Class; + } else if (this.finalMarks >= 60) { + this.grade = Grade.Second_Upper_Class; + } else if (this.finalMarks >= 50) { + this.grade = Grade.Second_Lower_Class; + } else { + this.grade = Grade.General_Pass; + } + } else if (this.finalMarks >= 30) { + this.grade = Grade.Fail_Resit; + } else { + this.grade = Grade.Fail_Retake; + } + return grade; + } +} diff --git a/src/StudentTester/Test.java b/src/StudentTester/Test.java new file mode 100644 index 0000000..4a77aa6 --- /dev/null +++ b/src/StudentTester/Test.java @@ -0,0 +1,632 @@ +package StudentTester; + +import GUI.Horizontal_View; +import GUI.Vertical_View; +import StudentClass.*; +import Comparators.*; + +import java.util.*; + +import static Enum.Grade.Fail_Resit; +import static Enum.Grade.Fail_Retake; + +public class Test { + + /* Class level variables so that they can be used anywhere in the class + referring to the name of it*/ + public static List students = new ArrayList<>(); + private static Scanner sc = new Scanner(System.in); + + // Method to get the average of the four components + private static List getComponentAverage() { + List average = new ArrayList<>(); + + double ict_01 = 0; + double ict_02 = 0; + double cw_01 = 0; + double cw_02 = 0; + + for (Student member : students) { + ict_01 = ict_01 + member.getIct_01_marks(); + ict_02 = ict_02 + member.getIct_02_marks(); + cw_01 = cw_01 + member.getCw_01_marks(); + cw_02 = cw_02 + member.getCw_02_marks(); + } + + ict_01 = ict_01 / students.size(); + ict_02 = ict_02 / students.size(); + cw_01 = cw_01 / students.size(); + cw_02 = cw_02 / students.size(); + + average.add(ict_01); + average.add(ict_02); + average.add(cw_01); + average.add(cw_02); + + return average; + } + + // Method to get the no: of students who has scores below 30 for the 4 components + private static List getComponentScoreBelow_30() { + List number = new ArrayList<>(); + + int ict_01 = 0; + int ict_02 = 0; + int cw_01 = 0; + int cw_02 = 0; + + for (Student member : students) { + if (member.getIct_01_marks() < 30) { + ict_01 = ict_01 + 1; + } + if (member.getIct_02_marks() < 30) { + ict_02 = ict_02 + 1; + } + if (member.getCw_01_marks() < 30) { + cw_01 = cw_01 + 1; + } + if (member.getCw_02_marks() < 30) { + cw_02 = cw_02 + 1; + } + } + + number.add(ict_01); + number.add(ict_02); + number.add(cw_01); + number.add(cw_02); + + return number; + } + + // Method to get the overall average(final score) + private static double overallAverage() { + int avg = 0; + + for (Student member : students) { + avg = avg + member.getFinalMarks(); + } + + avg = avg / students.size(); + return avg; + } + + // Method to get the list of students who are below the overall average + private static List belowAverageStudents() { + List belowAverage = new ArrayList<>(); + + for (Student member : students) { + if (member.getFinalMarks() < overallAverage()) { + belowAverage.add(member); + } + } + + return belowAverage; + } + + // Method to get the list of students who are above the overall average + private static List aboveAverageStudents() { + ArrayList aboveAverage = new ArrayList<>(); + + for (Student member : students) { + if (member.getFinalMarks() > overallAverage()) { + aboveAverage.add(member); + } + } + + aboveAverage = bubbleSort(aboveAverage, new LastName()); + + return aboveAverage; + } + + // Method to get the highest scorers for the four components and the overall module + private static List> highestScorer() { + + List> highScorer = new ArrayList<>(); + List ict_01 = new ArrayList<>(); + List ict_02 = new ArrayList<>(); + List cw_01 = new ArrayList<>(); + List cw_02 = new ArrayList<>(); + List overall = new ArrayList<>(); + + int ict_1_high_score = 0; + int ict_2_high_score = 0; + int cw_1_high_score = 0; + int cw_2_high_score = 0; + int overall_high_score = 0; + + for (Student member : students) { + if (member.getIct_01_marks() > ict_1_high_score) { + ict_1_high_score = member.getIct_01_marks(); + } + if (member.getIct_02_marks() > ict_2_high_score) { + ict_2_high_score = member.getIct_02_marks(); + } + if (member.getCw_01_marks() > cw_1_high_score) { + cw_1_high_score = member.getCw_01_marks(); + } + if (member.getCw_02_marks() > cw_2_high_score) { + cw_2_high_score = member.getCw_02_marks(); + } + if (member.getFinalMarks() > overall_high_score) { + overall_high_score = member.getFinalMarks(); + } + } + + for (Student member : students) { + if (member.getIct_01_marks() == ict_1_high_score) { + ict_01.add(member); + } + if (member.getIct_02_marks() == ict_2_high_score) { + ict_02.add(member); + } + if (member.getCw_01_marks() == cw_1_high_score) { + cw_01.add(member); + } + if (member.getCw_02_marks() == cw_2_high_score) { + cw_02.add(member); + } + if (member.getFinalMarks() == overall_high_score) { + overall.add(member); + } + } + + highScorer.add(ict_01); + highScorer.add(ict_02); + highScorer.add(cw_01); + highScorer.add(cw_02); + highScorer.add(overall); + + return highScorer; + } + + // Method to get the lowest overall scorer + private static List lowestScorer() { + List lowestScorer = new ArrayList<>(); + Student lScorer = students.get(0); + + for (Student member : students) { + if (member.getFinalMarks() < lScorer.getFinalMarks()) { + lScorer = member; + } + } + + for (Student member : students) { + if (lScorer.getFinalMarks() == member.getFinalMarks()) { + lowestScorer.add(member); + } + } + + return lowestScorer; + } + + // Method to get the list of retake students + private static List retakeStudents() { + List retake = new ArrayList<>(); + + for (Student member : students) { + if (member.getGrade().equals(Fail_Retake)) { + retake.add(member); + } + } + + return retake; + } + + // Method to get the list of resit students for each component + private static List> resitStudents() { + + List> all = new ArrayList<>(); + ArrayList ict = new ArrayList<>(); + ArrayList cw_1 = new ArrayList<>(); + ArrayList cw_2 = new ArrayList<>(); + + for (Student member : students) { + if (member.getGrade().equals(Fail_Resit) && ((member.getIct_01_marks() + member.getIct_02_marks()) / 2) < 40) { + ict.add(member); + } + if (member.getGrade().equals(Fail_Resit) && member.getCw_01_marks() < 40) { + cw_1.add(member); + } + if (member.getGrade().equals(Fail_Resit) && member.getCw_02_marks() < 40) { + cw_2.add(member); + } + } + + bubbleSort(ict, new LastName()); + bubbleSort(cw_1, new LastName()); + bubbleSort(cw_1, new LastName()); + + all.add(ict); + all.add(cw_1); + all.add(cw_2); + + return all; + } + + // Method to get back to the menu after each selection from the main menu + private static void backToMenu() { + System.out.print("Press enter to go back to the menu"); + sc.nextLine(); + System.out.println(); + } + + // Method to validate the marks which are entered by the user to the system + private static int marksValidation(Scanner sc, String message) { + int number; + do { + System.out.print(message); + while (!sc.hasNextInt()) { + System.out.println("Invalid input format. Please enter an integer" + "\n"); + System.out.print(message); + sc.next(); + } + number = sc.nextInt(); + if (number < 0 || number > 100) { + System.out.println("Number Range should be between 0-100 inclusive"); + } + } while (number < 0 || number > 100); + return number; + } + + // Method to sort an array list with the help of a comparator and return the result as an array list + private static ArrayList bubbleSort(ArrayList arrayList, Comparator comparator) { + Student temp; + + for (int i = 0; i < arrayList.size(); i++) { + for (int j = 1; j < (arrayList.size() - i); j++) { + if (comparator.compare(arrayList.get(j - 1), arrayList.get(j)) < 0) { + temp = arrayList.get(j - 1); + arrayList.set(j - 1, arrayList.get(j)); + arrayList.set(j, temp); + } + } + } + return arrayList; + } + + public static void main(String[] args) { + + System.out.println("Made by : Dehami Deshan Koswatte"); + System.out.println("IIT No : 2016198"); + System.out.println("Westminster No : w1673620\n"); + + // To keep repeating the loop + while (true) { + + // Variables which are used to show and clear messages as they are used repetitively + ArrayList messages = new ArrayList<>(); + int count = 0; + + // The menu which is shown to the user for selection + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + System.out.println("<<<< |||| 1. Enter Student Data |||| >>>>"); + System.out.println("<<<< |||| 2. Component Average |||| >>>>"); + System.out.println("<<<< |||| 3. Overall Average |||| >>>>"); + System.out.println("<<<< |||| 4. Highest Component Scorer |||| >>>>"); + System.out.println("<<<< |||| 5. Lowest Overall Scorer |||| >>>>"); + System.out.println("<<<< |||| 6. Students Above Average |||| >>>>"); + System.out.println("<<<< |||| 7. Students Below Average |||| >>>>"); + System.out.println("<<<< |||| 8. No:of Students Below Average for each Component |||| >>>>"); + System.out.println("<<<< |||| 9. Resit Students for each Component |||| >>>>"); + System.out.println("<<<< |||| 10. Retake Students |||| >>>>"); + System.out.println("<<<< |||| 11. Horizontal Histogram |||| >>>>"); + System.out.println("<<<< |||| 12. Vertical Histogram |||| >>>>"); + System.out.println("<<<< |||| 13. Exit |||| >>>>"); + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + System.out.print("\nPlease select a number from the above menu : "); + + String choice = sc.nextLine(); + + // Switch case would allow to direct to the certain case which the user would select from the menu + switch (choice) { + case "1": + + char cont; + System.out.println("\nYou selected number 1 Enter Student Data"); + + // Keep getting information until the user wants to stop + do { + System.out.println(); + System.out.print("Student Registration Number : "); + int regNo = sc.nextInt(); + sc.nextLine(); + System.out.print("Student First Name : "); + String fName = sc.nextLine(); + System.out.print("Student Last Name : "); + String lName = sc.nextLine(); + int ict_01 = marksValidation(sc, "ICT 01 Score : "); + int ict_02 = marksValidation(sc, "ICT 02 Score : "); + int cw_01 = marksValidation(sc, "CW 01 Score : "); + int cw_02 = marksValidation(sc, "CW 02 Score : "); + + Student student = new Student(fName, lName, regNo, ict_01, ict_02, cw_01, cw_02); + students.add(student); + + System.out.println("Grade Obtained : " + student.getGrade()); + System.out.println("Overall Marks : " + student.getFinalMarks()); + + System.out.print("\nPress 1 to continue and 0 to go back to main menu : "); + cont = sc.next().charAt(0); + } while (cont != '0'); + + backToMenu(); + break; + + case "2": + + messages.add("ICT 01 Average : "); + messages.add("ICT 02 Average : "); + messages.add("CW 01 Average : "); + messages.add("CW 02 Average : "); + + System.out.println("\nYou selected number 2 Component Average\n"); + + // Ensure that data is available before processing + if (students.size() != 0) { + for (double member : getComponentAverage()) { + System.out.print(messages.get(count)); + System.out.println(member); + count = count + 1; + } + System.out.println(); + messages.clear(); + count = 0; + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "3": + + System.out.println("\nYou selected number 3 Overall Average\n"); + + // Ensure that data is available before processing + if (students.size() != 0) { + System.out.println("Overall Average : " + overallAverage() + "\n"); + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "4": + + System.out.println("\nYou selected number 4 Highest Component Scorer\n"); + + int rep = 0; + + // Ensure that data is available before processing + if (students.size() != 0 && highestScorer().size() != 0) { + for (List member : highestScorer()){ + for (Student student : member){ + if (rep == 0) { + System.out.println("ICT_1 Highest Scorer/s ; \n"); + } else if (rep == 1) { + System.out.println("ICT_2 Highest Scorer/s ; \n"); + } else if (rep == 2){ + System.out.println("CW_1 Highest Scorer/s ; \n"); + }else if (rep == 3){ + System.out.println("CW_2 Highest Scorer/s ; \n"); + }else { + System.out.println("Overall Highest Scorer/s ; \n"); + } + System.out.println("Registration No : " + student.getRegNo()); + System.out.println("First Name : " + student.getfName()); + System.out.println("Last Name : " + student.getlName()); + System.out.println("ICT 01 Score : " + student.getIct_01_marks()); + System.out.println("ICT 02 Score : " + student.getIct_02_marks()); + System.out.println("CW 01 Score : " + student.getCw_01_marks()); + System.out.println("CW 02 Score : " + student.getCw_02_marks()); + System.out.println("Grade Obtained : " + student.getGrade()); + System.out.println("Class Average : " + overallAverage()); + System.out.println("Overall Score : " + student.getFinalMarks() + "\n"); + } + System.out.println("========================================================"); + rep++; + } + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "5": + + System.out.println("\nYou selected number 5 Lowest Overall Scorer\n"); + + // Ensure that data is available before processing + if (students.size() != 0 && lowestScorer().size() != 0) { + for (Student member : lowestScorer()) { + System.out.println("Registration No : " + member.getRegNo()); + System.out.println("First Name : " + member.getfName()); + System.out.println("Last Name : " + member.getlName()); + System.out.println("ICT 01 Score : " + member.getIct_01_marks()); + System.out.println("ICT 02 Score : " + member.getIct_02_marks()); + System.out.println("CW 01 Score : " + member.getCw_01_marks()); + System.out.println("CW 02 Score : " + member.getCw_02_marks()); + System.out.println("Grade Obtained : " + member.getGrade()); + System.out.println("Class Average : " + overallAverage()); + System.out.println("Overall Score : " + member.getFinalMarks() + "\n"); + } + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "6": + + System.out.println("\nYou selected number 6 Students Above Average\n"); + + // Ensure that data is available before processing + if (students.size() != 0 && aboveAverageStudents().size() != 0) { + for (Student member : aboveAverageStudents()) { + System.out.println("Registration No : " + member.getRegNo()); + System.out.println("First Name : " + member.getfName()); + System.out.println("Last Name : " + member.getlName()); + System.out.println("Grade Obtained : " + member.getGrade()); + System.out.println("Class Average : " + overallAverage()); + System.out.println("Overall Score : " + member.getFinalMarks() + "\n"); + } + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "7": + + System.out.println("\nYou selected number 7 Students Below Average\n"); + + // Ensure that data is available before processing + if (students.size() != 0 && belowAverageStudents().size() != 0) { + for (Student member : belowAverageStudents()) { + System.out.println("Registration No : " + member.getRegNo()); + System.out.println("First Name : " + member.getfName()); + System.out.println("Last Name : " + member.getlName()); + System.out.println("Grade Obtained : " + member.getGrade()); + System.out.println("Class Average : " + overallAverage()); + System.out.println("Overall Score : " + member.getFinalMarks() + "\n"); + } + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "8": + + System.out.println("\nYou selected number 8 No:of Students " + + "Below Average for each Component\n"); + + messages.add("ICT 01 : "); + messages.add("ICT 02 : "); + messages.add("CW 01 : "); + messages.add("CW 02 : "); + + // Ensure that data is available before processing + if (students.size() != 0 && getComponentScoreBelow_30().size() != 0) { + for (int member : getComponentScoreBelow_30()) { + System.out.print(messages.get(count)); + System.out.println(member); + count = count + 1; + } + System.out.println(); + messages.clear(); + count = 0; + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "9": + + System.out.println("\n You selected number 9 Resit Students for each " + + "Component\n"); + + int counter = 0; + + // Ensure that data is available before processing + if (students.size() != 0 && resitStudents().size() != 0) { + for (List member : resitStudents()) { + if (counter == 0) { + System.out.println("ICT Resit Students ; \n"); + } else if (counter == 1) { + System.out.println("CW_1 Resit Students ; \n"); + } else { + System.out.println("CW_2 Resit Students ; \n"); + } + for (Student student : member) { + System.out.println("Registration No : " + student.getRegNo()); + System.out.println("First Name : " + student.getfName()); + System.out.println("Last Name : " + student.getlName()); + System.out.println("ICT 01 Score : " + student.getIct_01_marks()); + System.out.println("ICT 02 Score : " + student.getIct_02_marks()); + System.out.println("CW 01 Score : " + student.getCw_01_marks()); + System.out.println("CW 02 Score : " + student.getCw_02_marks()); + System.out.println("Class Average : " + overallAverage()); + System.out.println("Overall Score : " + student.getFinalMarks() + "\n"); + } + System.out.println("========================================================"); + counter++; + } + }else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + + backToMenu(); + break; + + case "10": + + System.out.println("\nYou selected number 10 Retake Students\n"); + + // Ensure that data is available before processing + if (students.size() != 0 && retakeStudents().size() != 0) { + for (Student member : retakeStudents()) { + System.out.println("Registration No : " + member.getRegNo()); + System.out.println("First Name : " + member.getfName()); + System.out.println("Last Name : " + member.getlName()); + System.out.println("Overall Score : " + member.getFinalMarks() + "\n"); + } + } else { + System.out.println("Cannot perform process due " + + "to the unavailability of data \n"); + } + + backToMenu(); + break; + + case "11": + + System.out.println("\nYou selected number 11 Horizontal Histogram\n"); + + new Horizontal_View(); + + backToMenu(); + break; + + case "12": + + System.out.println("\nYou selected number 12 Vertical Histogram\n"); + + new Vertical_View(); + + backToMenu(); + break; + + case "13": + + System.out.println("\nYou selected number 13 Exit\n"); + + // Exiting from the system + System.exit(0); + break; + + default: + // If an invalid selection is made at the main menu + System.out.println("\nInvalid selection through menu. Please try again\n"); + break; + } + } + } +}