Programming Assignment 4.8
Change the Student class so that each student object also contains the scores for three tests.
a. Provide a constructor that sets all instance values based on parameter values.
b. Overload the constructor so that each test score starts out at zero.
c. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score.
d. Also provide a method called getTestScore that accepts the test number and returns the score.
e. Provide a method called average that computes and returns the average test score for this student.
f. Modify the toString method so that the test scores and average are included in the description of the student.
g. Modify the driver class main method to exercise the new Student methods.
h. Add to your test class a feature to calculate the highest and lowest average grades of at least 5 students.
//******************************************************************** // Student.java Author: Lewis/Loftus/Cocking // // Represents a college student. //******************************************************************** public class Student { private String firstName, lastName; private Address homeAddress, schoolAddress; //----------------------------------------------------------------- // Sets up this Student object with the specified initial values. //----------------------------------------------------------------- public Student (String first, String last, Address home, Address school) { firstName = first; lastName = last; homeAddress = home; schoolAddress = school; } //----------------------------------------------------------------- // Returns this Student object as a string. //----------------------------------------------------------------- public String toString() { String result; result = firstName + " " + lastName + "\n"; result += "Home Address:\n" + homeAddress + "\n"; result += "School Address:\n" + schoolAddress; return result; } }