public class Student { private String name; // every Student has a name (this is not the only instance variable) public String getName() { // accessor for the name instance variable return name; } Student() { } // default constructor to create a volunteer (no name, etc.) Student(String givenName) { // constructor to create a Student object with the given name name = givenName; } void addQuiz(int newScore) { // add a new score: we need a variable to remember the total score thus far totalScore = totalScore + newScore; numberOfScores = numberOfScores + 1; // we also need a variable that counts how many scores we've collected thus far } private int totalScore; // here's the instance variable we need to keep track of scores int getTotalScore() { // instance method: accessor for the totalScore return totalScore; } private int numberOfScores; // instance variable storing the number of scores; incremented by addQuiz double getAverageScore() { // instance method to report the average score: return (double)totalScore / numberOfScores; // divide the sum by the number of scores } public static void main(String[] args) { // main method as indicated in the homework assignment Student a = new Student("Larry"); a.addQuiz(10); // this is file: Student.java a.addQuiz(9); // compile with javac Student.java a.addQuiz(8); // run with: java Student System.out.println("Grade report for: " + a.getName()); System.out.println("Total score: " + a.getTotalScore()); System.out.println("Average score: " + a.getAverageScore()); } }