A list of students (student ID, first name, last name, list of 4 test grades) will be transformed into Student objects. We will provide this file for you. a. Each feature will be separated by commas, however; the grades will be separated by spaces, as shown in this example line: 82417619,Erik,Macik,95.6 85 100 88 [Hint: It seems like you might need to use the split method twice] b. Your program should work with any file with any number of lines.
1. A list of students (student ID, first name, last name, list of 4 test grades) will be transformed into
Student objects. We will provide this file for you.
a. Each feature will be separated by commas, however; the grades will be separated by
spaces, as shown in this example line: 82417619,Erik,Macik,95.6 85 100 88
[Hint: It seems like you might need to use the split method twice]
b. Your program should work with any file with any number of lines.
2. A menu will be displayed on loop to the user (meaning after a user completes a selection, the
menu will be displayed again, unless the user exits).
The menu options should be the following:
a. View Student Grade and Average
b. Get Test Average
c. Get Top Student per exam
d. Exit
3. Your system shall incorporate the following classes. Each class will require one file.
GRADE CALCULATOR
Purpose
A class that contains useful methods that can be used to calculate averages and
convert grades to letter grades
Attributes: None
Methods
convertToLetterGrade(double grade): This method will return the letter
grade of a given a test score or average grade. In this case, if we are given a grade
that is greater than 100 or less than 0, we will return ‘E’. Use this conversion chart:
A 90 <= grade <= 100
B 80 <= grade < 90
C 70 <= grade < 80
D 60 <= grade < 70
F 0 <= grade < 60
E Otherwise
calculateAverage(double[] grades): Given a list of grades, return the
average grade.
STUDENT
Purpose
A class that will represent a student from the file. In the file, each line represents a
student
Attributes
private int studentId;
[CS1101] Comprehensive Lab 3
private String firstName;
private String lastName;
private double[] grades;
Methods
Student(): The default constructor for the Student class.
Student(String studentId, String firstName, String lastName,
double[] grades): The constructor for the Student class that receives all
attributes for a Student. HINT: Be sure not to pass a String[] for grades. Grades is a
double[].
Getters and Setters: Create a getter and setter for each attribute of the
Student class.
calculateAverage(): This method will calculate and return the average grade of
the Student. If the student has no grades, return 0.0.
calculateLetterGrade(): This method will calculate and return the letter grade
of the student. HINT: first call calculateAverage(), then use GradeCalculator to
convert the average to a letter grade.
viewGrades(): This method will display all grades of the Student.
toString(): This method will return a String containing the studentId, firstName,
and lastName of the Student.
Purpose
Stores an array of Student objects. This class contains methods to populate the
database, view students in the database, and calculate student and test averages.
Attributes
private String filename;
private Student[] studentList;
private int numOfTests;
Methods
Database(String fileName): The constructor for the Database class.
Receives the filename that this database will be constructed from.
getNumberOfStudents(): This method will traverse through the file and return
the number of students (number of lines) that exist in the file. This method does not
receive any arguments.
populateDatabase(): This method will traverse every line of the file, create a
Student object from every line, and store them in studentList. This method does not
receive any arguments. HINT: Use getNumberOfStudents() to figure out how large
to make the studentList array.
viewListOfStudents(): This method displays ID number, first name, and last
name of every student in the database.
getStudent(int studentId): This method returns the Student object in the
database with the matching studentId. If the student does not exist, return null.
getStudentAvg(int studentId): Given a studentId, this method will return
the grade of the corresponding student in the database. If the student does not
exist in the database, return -1.0.
getTestAvg(int testNum): Given a testNum, this method will return the
average test grade over all students in the database. If the test does not exist,
return -1.0.
viewTopStudentPerExam(): This method will display the name of the student
with the highest grade per exam.
RUNNER
[IMPORTANT: Runner will primarily interact with the Database class. Runner should not
create any Student objects.]
Methods
main method
File:
id,First Name,Last Name,Test1 Test2 Test3 Test4
82417619,Erik,Macik,95.6 85 100 88
88557812,Ali,Pashamohammad,75.2 87 97 96
88915283,Ana,Arellano,78 79.3 92 64.3
87734896,Montserrat,Molina,67 99.7 90 74
85119645,Manuel,Gutierrez,87 94.6 89 69.4
80080012,Melina,Salazar,65.2 84 75 86
88011201,Joshua,Ramos,98.2 74 85.4 97
80001234,Diana,Licon,98.6 85 98 100
80512311,Ericka,Najera,95.6 75.1 85 92
80123456,Lorelyne,Chavez,100 94.2 87.6 91
Step by step
Solved in 3 steps with 17 images