Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago