Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(a) Implement a class Student. For the purpose of this exercise, a student has a

ID: 3763817 • Letter: #

Question

(a) Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods getName(), addQuiz(score), getTotalScore(), and getAverageScore(). To compute the latter, you also need to store the number of quizzes that the student took. (b) Modify the Student class to compute grade point averages. Methods are needed to add a grade and get the current GPA. Specify grades as elements of a class Grade. Supply a constructor that constructs a grade from a string, such as ”B+”. You will also need a method that translates grades into their numeric values (for example, ”B+” becomes 3.3). [You may obtain traditional grading scales from here http://en.wikipedia.org/wiki/Academic_grading_in_the_United_States]

Explanation / Answer

a)  

}

b)

public class P8_07 { private String name; private double totalScore; private int scoreCount; public P8_07(String name) { this.name = name; } public String getName() { return this.name; } public void addQuiz(double score) { this.totalScore += score; this.scoreCount += 1; } public double getTotalScore() { return this.totalScore; } public double getAverageScore() { return this.totalScore / this.scoreCount; }

}

b)

public class P8_08 { private String name; private double totalScore; private int scoreCount; public P8_08(String name) { this.name = name; } public String getName() { return this.name; } public void addQuiz(double score) { this.totalScore += score; this.scoreCount += 1; } public void addQuiz(Grade grade) { this.totalScore += grade.getScore(); this.scoreCount += 1; } public double getTotalScore() { return this.totalScore; } public double getAverageScore() { return this.totalScore / this.scoreCount; } }