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

Can you post again the code using code tags?
Just click the button (CODE) and put your code between the tags.

Can you post again the code using code tags?
Just click the button (CODE) and put your code between the tags.

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;

             }


             //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 ");

   */

    //if(begin == length-1){


  //end Project02

This makes no sense to me. What are you attempting to do in your switch statement? What is an example of the final output supposed to look like? I suggest you break down the problem (on paper) into simple steps and start over. Use separate methods to address each area of the problem/solution. What you have right now is a monolithic approach and (not to be insulting) a lot of thrashing around.

Simplify, simplify, simplify.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.