Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program for grade distribution. For this assignment you will write a class called GradeDistribution.java that represents a collection of grades, and then

Write a java program for grade distribution.

For this assignment you will write a class called GradeDistribution.java that represents a collection of grades, and then you will write a program TestGradeDistribution.java that tests your GradeDistribution class.

Your GradeDistribution class should have the following private instance variables, all of which are of type int. (You can copy and paste this list of variables into your code.)

lowest

highest

numberOfAs

numberOfABs

numberOfBs

numberOfBCs

numberOfCs

numberOfCDs

numberOfDs

numberOfDFs

numberOfFs

For this assignment, grades are classified according to the following grading scale.

A

93 - 100

AB

88 - 92

B

83 - 87

BC

78 - 82

C

73 - 77

CD

68 - 72

D

63 - 67

DE

58 - 62

F

57 or less

Your GradeDistribution class should have the following public instance methods. Copy and paste this list into your code and then complete the definition for each method.

void enterGrade(int grade)

int getLowest()

int getHighest()

int getTotalNumberOfGrades()

int getNumberOfAs()

int getNumberOfABs()

int getNumberOfBs()

int getNumberOfBCs()

int getNumberOfCs()

int getNumberOfCDs()

int getNumberOfDs()

int getNumberOfDFs()

int getNumberOfFs()

int getPerCentA()

int getPerCentAB()

int getPerCentB()

int getPerCentBC()

int getPerCentC()

int getPerCentCD()

int getPerCentD()

int getPerCentDF()

int getPerCentF()

void drawGraph()

The enterGrade() method accepts a grade as its parameter and then classifies that grade (which means add 1 to the appropriate instance variable). This method should also determine if the grade is a new highest or lowest grade. Notice that this method enters grades into the GradeDistribution object that it is part of. This is the only way to modify the data stored in a GradeDistribution object. Also notice that it is this method's parameter that is the grade to record in the object. This method should not prompt a user for any data.

Each getPerCent?() method should compute the percentage of its number of grades out of the total number of grades. This should be calculated like this.

(int)Math.round( (100.0 * numberOf?s) / getTotalNumberOfGrades() )

The drawGraph() method outputs a bar graph of the grade distribution. In the zip file there is a demo version of this assignment. You can run the demo version to see exactly how your bar graph is supposed to look (see details below).

When your GradeDistribution class is done, you can test it in DrJava's interactions pane with interactions like this.

> GradeDistribution gd = new GradeDistribution()

> gd.enterGrade(68)

> gd.enterGrade(75)

> gd.enterGrade(61)

> gd.enterGrade(88)

> gd.getNumberOfCs()

> gd.getPerCentC()

> gd.getTotalNumberOfGrades()

> gd.getHighest()

> gd.drawGraph()

> gd.enterGrade(94)

> gd.getHighest()

> gd.drawGraph()

> GradeDistribution gd2 = new GradeDistribution()

> gd2.enterGrade(95)

> gd2.enterGrade(94)

> gd2.enterGrade(85)

> gd2.enterGrade(84)

> gd2.drawGraph()

> gd.drawGraph()

Write a program TestGradeDistribution.java that is similar to your Hw4.java program. Your TestGradeDistribution.java program should, like Hw4.java, read grades from "standard input" and the inputting of grades should be terminated by any negative number. But your TestGradeDistribution.java program should not keep its own statistics (like Hw4.java did). Instead, your program should create a GradeDistribution object and, for each grade that is read in, use the enterGrade() method to enter the grade into the GradeDistribution object. That way, the GradeDistribution object does the work of calculating, keeping, and reporting the statistics on all the grades.

When your TestGradeDistribution.java program is done, you can test it with your GradeDistribution class using a Windows command prompt and two programs from the zip file called CreateRandomGrades.java and CreateRandomCurvedGrades.java. These two programs generate random grades that can be used as input to your TestGradeDistribution.java program. At a Windows command prompt, opened in your hw5 folder, try the command

C:\hw6> java CreateRandomGrades 20

You should see twenty random grades. You can run the random grades into your test program by using the following command. This command makes your TestGradeDistribution program read its input directly from the output of the CreateRandomGrades program.

C:\hw6> java CreateRandomGrades 20 | java TestGradeDistribution

In the zip file there are compiled demo versions of this assignment that you can run to see exactly how the output from your TestGradeDistribution.java program should look. To make sure your program creates the correct output, type the following sequence of commands at the Windows command prompt.

C:\hw6> java CreateRandomGrades 20 > data.txt

C:\hw6> java TestGradeDistribution_Demo < data.txt

C:\hw6> java TestGradeDistribution < data.txt

The first command creates a data file of grades. The second command runs that data file into the demo version of this assignment and produces the correct output. The third command runs that same data file through your version of the assignment. Your version should produce the exact same output as the demo version.

The drawGraph() method should draw only the bar graph (with its scale). All the other output should be from the TestGradeDistribution.java program, but it should be getting the statisitcs from its GradeDistribution object using the object's acesssor ("get") methods.

Turn in a zip file called CS123Hw6Surname.zip (where Surname is your last name) containing your version of GradeDistribution.java and TestGradeDistribution.java.

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

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago