- 7 2 Student Modify The Student Class Presented In This Chapter As Follows Each Student Object Should Also Contain The 1 (58.74 KiB) Viewed 7 times
7.2: Student Modify the Student class presented in this chapter as follows: Each Student object should also contain the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
7.2: Student Modify the Student class presented in this chapter as follows: Each Student object should also contain the
7.2: Student Modify the Student class presented in this chapter as follows: Each Student object should also contain the (integer) scores for three tests. Provide a constructor that sets all instance values based on parameter values, with the score parameters coming last in the list. Overload the constructor so that each test score is assumed to be initially zero. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and returns the appropriate score. Provide a method called average that computes and returns an integer average test score (the average rounded to the nearest integer) for this student. Modify the toString method so that the test scores and average are included in the description of the student. The String returned should be the same as the original with a string of this form appended as an additional line: Average=A with Tests: S1, S2, S3 where A is the (integer) average and S1 S2 and S3 are the test scores SUBMIT 11 public class Student { 16 17 } 18 RESET private String firstName, lastName; private Address homeAddress, schoolAddress; public Student (String first, String last, Address home,Address school) { firstName= first; } lastName = last; homeAddress = home; schoolAddress = school; } public String toString() { String result; result = firstName + " " + lastName + "\n"; result += "Home Address: \n" + homeAddress + "\n"; result += "School Address: \n" + schoolAddress + "\n"; return result; 5 of 5: Sun Jul 03 2022 19:41:13 GMT-0500 (Central Daylight Time) ✓