Objectives 1 define a Java class and its methods 2 create an
Objectives:
(1) define a Java class and its methods.
(2) create and use objects of a class.
Instructions:
(1) Create a class that represents the grade distribution for a given course. Write a method or methods to perform the following tasks:
• Uses a random number generator to develop a set of 100 numbers representing a Gaussian distribution of grades with a mean of 70% and standard deviation of 10.
• Calculates and returns the percentage of each letter grade as a whole number between 0 and 100, inclusive.
• Draw a bar graph of the grade distribution.(Extra Credit:draw vertical bar graph)
The graph will have five bars, one per grade. Each bar can he a horizontal row of asterisks, such that the number of asterisks in a row is proportionate to the percentage of grades in each category. Let one asterisk represent 2 percent, so 50 asterisks correspond to 100 percent. Mark the horizontal axis at 10 percent increments from 0 to 100 percent, and label each line with its letter grade.
For example, if the grades are 1 A, 4 Bs, 6 Cs, 2 Ds, and I F, the total number of grades is 14, the percentage of As is 7, the percentage of Bs is 29. the percentage of Cs is 43, the percentage of Ds is 14, and the percentage of Fs is 7. The A row would contain 4 asterisks (7 percent. of 50 rounded to the nearest integer), the 11 row 14, the C row 21, the D row 7, and the F row 4. The graph would look like this:
0 10 20 30 40 50 60 70 80 90 100%
| | | | | | | | | | |
***************************************************
**** A
************** B
********************* C
******* D
**** F
Solution
Here is the given program and please let me know if any errors occurs
import java.util.Scanner;
import java.io.*;
public class Project02
{
public static void main(String[] args)
{
{
System.out.println(\"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **\");
System.out.println(\"* Programmer: Tandica Beckford Program Name: Project02.java *\");
System.out.println(\"* Course: CIS 2200 Instructor: C. A. Thomas *\");
System.out.println(\"* Assignment: Project #1 Due Date: 29 Mar 11 *\");
System.out.println(\"* Date Created: 21 Feb 11 Date Revised: 25 Mar 11 *\");
System.out.println(\"* Input: Keyboard *\");
System.out.println(\"* Output: Screen Report *\");
System.out.println(\"* Methods Used: main, clrscr(), etc *\");
System.out.println(\"* User Methods Invoked: print header() printfcn() *\");
Scanner kb = new Scanner (System.in);
}
{
System.out.println(\"******************************************************\");
System.out.println(\"This program will present the number of grades\" ); //INTRODUCTION
System.out.println(\"you input for grades A-F and turn this information\"); //TO
System.out.println(\"in to a bar graph for ease.\"); //PROGRAM
System.out.println(\"******************************************************\");
System.out.println(\" \");
}
for(double loopcounter=0; loopcounter<5; loopcounter++)
/**
}
case 0: \"\\grade A: |\"; break;
case 1: \"\\grade B: |\"; break;
case 3: \"\\grade C: |\"; break;
case 4: \"\\grade D: |\"; break;
case 5: \"\\grade F: |\"; break;
}
for(double asteriskcounter=0; asteriskcounter<array[loopcounter]/2; asteriskcounter++)
System.out.println (\'*\');
System.out.println(\"| \" << array[loopcounter] << \'%\');
}
percent=100/14; // 7;
System.out.println(\" \");
System.out.println(\" TOTAL GRADES ENTERED - \");
char[] line = percent*a/2;//3; Bcent=percent*b/2; Ccent=percent*c/2; Dcent=percent*d/2; Ecent=percent*e/2; Fcent=percent*f/2;
}
System.out.println(\" 0 10 20 30 40 50 60 70 80 90 100\");
System.out.println(\" | | | | | | | | | | |\");
System.out.println(\" **************************************************\");
double array[6] = {Acent, Bcent, Ccent, Dcent, Ecent, Fcent};
char[] line = array2[6] = {\'A\',\'B\',\'C\',\'D\',\'E\',\'F\'}; //stores letters a-f
for(double loopcounter=0; loopcounter<6; loopcounter++)
{
System.out.println(\" \");
for(double asteriskcounter=0; asteriskcounter<array[loopcounter]; asteriskcounter++)
System.out.println(\"*\");
}
System.out.prdoubleln(\" GRADE \");
if(begin == length-1)
{


