Starting from:
$24.99

$18.99

Assignment #12 Solution (Best price and Top Grade Guaranteed)

Goal: Compute a histogram of letter grades entered from the keyboard.
Create a class named GradeHistogram that includes a method inputData () that reads a series of letter grades (A, B, C, D, F) from the user and counts the number of times each grade occurs. The grades are entered one per line. Enter a ‘Z’ to signal the end of input. The grades can occur in any order. Accept both upper and lower case. For example ‘A’ and ‘a’ are the same grade. Don't assume any upper limit for the number of grades.
Count the number of times a letter that is not a grade has been entered. The method showData() writes out the histogram.
Write the program with a class definition of GradeHistogram and a separate class definition GHTester that contains the static main() method. The main() method creates a GradeHistogram object and call that object’s inputData () method to read and process the data.

Store the grade frequencies in an array of integers. Use a separate variable to contain the number of errors. You must use an array for this program since the purpose is practice with arrays.
Do not write this program with just a single class. Write a driver class HistoTester which contains main(), which instantiates a GradeHistogram and uses its methods. Here is an example of the program working:

Enter Grade: C
Enter Grade: A
Enter Grade: D
Enter Grade: c
Enter Grade: S
Enter Grade: a
Enter Grade: Z
Grade Frequency
----- ---------
A 2
B 0
C 2
D 1
F 1
errors 1
Class Average: 2.6

Expect much more input than shown here.
You will need: A while loop that keeps going until the user inputs a Z. You may also need to use the charAt() method of the String to get a single character from
the user's input.

Program Outline:
import java.util.*;
public class GradeHistogram
{
. . . instance variables . . .
public void inputData()
{
...fill in here...
}
public void showData()
{
...fill in here...
}
public double classAverage()
{
...fill in here...
}
}
// Driver class
public class HistoTester
{
public static void main ( String[] args )
{
GradeHistogram gradeHist = new GradeHistogram();
gradeHist.inputData();
gradeHist.showData();
. . .
}
}
What to turn in: Turn in GradeHistogram.java and HistoTester.java. At the top of your source files includ

More products