implement a class
DESCRIPTION
java codeTRANSCRIPT
Implement a classStudent. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methodsgetName(),addQuiz(int score),getTotalScore(), andgetAverageScore(). To compute the latter, you also need to store thenumber of quizzesthat the student took. Supply aStudentTesterclass that tests all methods.Complete the following class as your tester class: /** This program tests the Student class. */ public class StudentTester { public static void main(String[] args) { Student student = new Student("Cracker, Carla");
// TODO: Add some quizzes
// TODO: Print actual and expected name, total score } } Complete the following class in your solution: /** A student who is taking quizzes. */ public class Student {
/** Constructs a student with a given name. @param n the name */ public Student(String n) { . . . }
/** Gets the name of this student. @return the name */ public String getName() { . . . }
/** Adds a quiz score. @param score the score to add */ public void addQuiz(int score) { . . . }
/** Gets the sum of all quiz scores. @return the total score */ public double getTotalScore() { . . . }
/** Gets the average of all quiz scores. @return the average score */ public double getAverageScore() { . . . } . . . }public class Student{ //instance fields private double score; private String name; private double quizzestaken; /** Constructs a student with a given name. * @param name */ public Student (String name) { name = "Billy"; quizzestaken = 3; } /** Gets the name of this student. @return the name */ public String getName() { return name; }
/** Adds a quiz score. @param score the score to add */ public void addQuiz(int score) { score = 24; }
/** Gets the sum of all quiz scores. @return the total score */ public double getTotalScore() { return score; }
/** Gets the average of all quiz scores. @return the average score */ public double getAverageScore() { double averageScore = (score / quizzestaken); return averageScore; } }