Create a class that represents the grade distribution for a given course. In this class you should write methods to perform the following tasks:
Read the number of each of the letter grades A, B, C D and F
Set the number of letter grades A, B, C, D and F
Return the total number of grades
Return the percentage of each letter grade as a whole number between 0 and 100 inclusive
Draw a bar graph of the grade distribution
The graph should have five bars, one per grade. Each bar can be a horizontal row of asterisks, such that the number of asterisks in a row is proportionate to the percentage of grades in each category. For example, let on asterisk represent 2%, so 50 asterisks correspond to 100%. Mark the horizontal axis at 10% increments from 0 to 100% and label each line with a letter grade.
For example, if the grades are entered as 1A, 4B's, 6C's, 2D's and 1 F, then the output would look like:
0 10 20 30 40 50 60 70 80 90 100
IIIIIIIIIII
**************************************************
**** A
************** B
******************** C
****** D
E
**** F
This is my code
import java.util.Scanner;
import java.io.*;
public class Project02
{
public static void main(String[] args)
{
print_header();
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++)
{
switch(loopcounter)
{
case 0: "\nGrade A: |"; break;
case 1: "\Grade B: |"; break;
case 3: "\Grade C: |"; break;
case 4: "\Grade D: |"; break;
case 5: "\Grade F: |"; break;
}
//loop to output each asterisk
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;
} //end;
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}; //stores grades as percentage
char[] line = array2[6] = {'A','B','C','D','E','F'}; //stores letters a-f
// loop for each grade
for(double loopcounter=0; loopcounter<6; loopcounter++)
{
System.out.println(" ");
// loop to output each asterisk
for(double asteriskcounter=0; asteriskcounter<array[loopcounter]; asteriskcounter++)
{
System.out.println("*");
}
// prdouble the grade after the asterisks
System.out.prdoubleln( " GRADE "[loopcounter]);
//end Project02
I am a novice at this. I am cannot get it to run properly. Please help me and how I can correct the problem.
Thank you