Question: JAVA. Modify the Student class of Lab6 to compute grade point averages. Methods are needed to add a grade and get the current GPA. Specify

JAVA. Modify the Student class of Lab6 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).

Here is my student class:

/**

*

* @author rhiannondore

* 2/10/19

* This is a class of constructors and methods used with StudentTester to get the names and average quiz scores of students

*

*/

public class Student {

//declare variables

String name;

int totalQuizScore;

int numOfQuizzes;

public Student(String name) {

this.name = name;

this.totalQuizScore = 0;

this.numOfQuizzes = 0;

}//main

//implement getName method

public String getName() {

return this.name;

}//getName

//implement getTotalScore method

public int getTotalScore() {

return this.totalQuizScore;

}//getTotalScore

//implement addQuiz method

public void addQuiz(int score) {

this.numOfQuizzes++;

this.totalQuizScore += score;

}//addQuiz

//implement getAverageScore method

public double getAverageScore() {

return this.totalQuizScore / this.numOfQuizzes;

}//getAverageScore

}//classStudent

Here is my studentTester class:

* Created by Rhiannon Dore * 2/4/19 * This is a tester class to prompt the user for a name and set of test scores that then displays them */ import java.util.Scanner;

public class StudentTester{

public static void main(String[] args) { //import scanner Scanner in = new Scanner(System.in);

//prompt user for student name System.out.print("Enter the student's first name: "); String name = in.next(); Student std = new Student(name);

//prompt user for quiz scores System.out.print("Enter a quiz score rounded to the nearest whole number(-1 to exit): "); int score = in.nextInt(); while(score>=0){ std.addQuiz(score); System.out.print("Enter a quiz score rounded to the nearest whole number(-1 to exit): "); score = in.nextInt();

}

//print name, total score, and average score System.out.println("Name: "+std.getName()); System.out.println("Total Score: "+std.getTotalScore()); System.out.println("Average Score: "+std.getAverageScore());

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!