Lab3 25 v2
Lab3 25 v2
1. The provided code uses static methods to calculate a student's average grade and
determine their letter grade (procedural programming). Your task is to refactor this
implementation into an object-oriented approach.
Instructions:
a) Create a `Student` class that:
- Stores the student's name and grades
-Has constructor Student(String name, int[] grades)
- Has a method `calculateAverage()` to compute the average grade.
- Has a method `determineGrade()` to determine the letter grade.
- Has a method `getName()` to retrieve the student's name.
a) Adding a static variable `TopStudentMath` to store the highest grade in the first
subject (assumed to be math) among all students.
b) Adding a static variable `TopStudentName` to store the name of the student
with the highest grade in the first subject.
c) Implementing a static method `getTopStudentName()` to return the name of the
student with the highest grade in the first subject.
d) Updating the constructor to check if the new student has a higher grade than
`TopStudentMath`, and update `TopStudentName` accordingly.
e) Try the following statements in the method getTopStudentName():
a. System.out.println(name); // Does it work, comment!
b. System.out.println(getName()); // Does it work, comment!
c. System.out.println(topStudentName); // Does it work, comment!
f) Try the following statements in the method determineGrade():
a. System.out.println(name); // Does it work, comment!
b. System.out.println(getName()); // Does it work, comment!
c. System.out.println(TopStudentName); // Does it work, comment!
Try the following code statements in the main method that uses the student class