Web Analytics Made Easy -
StatCounter Java Grading Program Help.....Range - CodingForum

Announcement

Collapse
No announcement yet.

Java Grading Program Help.....Range

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java Grading Program Help.....Range

    I have everything done...but me and my friends in class cant figure out how to do the high and low score (range) i think my teacher said something about it beint just simple if statements but i figure it out....if anyone has any ideas let me know


    // 80 Point Version
    //
    // Write a program to read a list of exam scores (numbers in the range 0 .. 100)
    // and to output the total number of grades and the number of grades in each
    // letter-grade category.(90-100=A, 80-89=B, 75-79=C, 70-74=D, 0-69=F).

    // Sample Output
    // Enter a grade (-1 to quit) --> 89
    // Enter a grade (-1 to quit) --> 70
    // Enter a grade (-1 to quit) --> 56
    // Enter a grade (-1 to quit) --> 113
    // 113 is an invalid grade
    // Enter a grade (-1 to quit) --> 100
    // Enter a grade (-1 to quit) --> 50
    // Enter a grade (-1 to quit) --> 77
    // Enter a grade (-1 to quit) --> 40
    //
    // Total number of grades: 7
    // Number of A's: 1
    // Number of B's: 1
    // Number of C's: 1
    // Number of D's: 1
    // Number of F's: 3


    // 100 Point version
    // Also print out the highest and lowest grades, the average, and percentage
    // of total for each letter grade.

    // 100 point version sample output
    // Enter a grade (-1 to quit) --> 89
    // Enter a grade (-1 to quit) --> 70
    // Enter a grade (-1 to quit) --> 56
    // Enter a grade (-1 to quit) --> 113
    // 113 is an invalid grade
    // Enter a grade (-1 to quit) --> 100
    // Enter a grade (-1 to quit) --> 50
    // Enter a grade (-1 to quit) --> 77
    // Enter a grade (-1 to quit) --> 40
    //
    // Total number of grades: 7
    // Number of A's: 1
    // Number of B's: 1
    // Number of C's: 1
    // Number of D's: 1
    // Number of F's: 3
    // Percentage of A's: 14.2857142%
    // Percentage of B's: 14.2857142%
    // Percentage of C's: 14.2857142%
    // Percentage of D's: 14.2857142%
    // Percentage of F's: 4285714285%
    // Range:
    // Highest Score: 100
    // Lowest Score: 40
    // Average Score: 68.857142857142

    import learning.*;

    public class GradeStats
    {
    public static void main(String[] args)
    {
    double grade;
    double average;
    double sum = 0;
    double count = 0;
    int numA = 0;
    int numB = 0;
    int numC = 0;
    int numD = 0;
    int numF = 0;
    int high = 0;
    int low = 0;
    double pa;
    double pb;
    double pc;
    double pd;
    double pf;

    do
    {
    System.out.print("Enter a grade(-1 to quit)-->");
    grade = LearningIO.readDouble();
    if(grade>100)
    System.out.println("Grade must be 0-100");
    }
    while(grade>100);

    while(grade>0)
    {
    sum+=grade;
    count+=1;
    if(grade >= 90)
    numA+=1;
    else if(grade >= 80)
    numB+=1;
    else if(grade >= 75)
    numC+=1;
    else if(grade >= 70)
    numD+=1;
    else if(grade >= 0)
    numF+=1;
    do
    {
    System.out.print("Enter a grade(-1 to quit)-->");
    grade = LearningIO.readDouble();
    if(grade>100)
    System.out.println("Grade must be 0-100");
    }
    while(grade>100);
    }

    System.out.println("Total number of grades " +count);
    System.out.println("Number of A's "+numA);
    System.out.println("Number of B's "+numB);
    System.out.println("Number of C's "+numC);
    System.out.println("Number of D's "+numD);
    System.out.println("Number of F's "+numF);

    pa = (numA/count)*100;
    System.out.println("Percentage of A's "+pa+"%");
    pb = (numB/count)*100;
    System.out.println("Percentage of A's "+pb+"%");
    pc = (numC/count)*100;
    System.out.println("Percentage of A's "+pc+"%");
    pd = (numD/count)*100;
    System.out.println("Percentage of A's "+pd+"%");
    pf = (numF/count)*100;
    System.out.println("Percentage of A's "+pf+"%");

    System.out.println("Range:");
    if()
    System.out.println("High Score:"+high);
    System.out.println("Low Score:"+low);


    average = sum/count;
    System.out.println("Your average is " +average);
    }
    }

  • #2
    Wrong forum my friend. Java is not Javascript. I suggest reading your book more.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      sorry didnt notice..still hope someone can help

      Comment


      • #4
        Good ol java...

        Wrong forum, but here's the idea.

        initialize the values
        high = 100;
        low = 0;

        two if statements will be used, one for high and one for low.

        if (grade > high) high = grade;
        if (grade < low) low = grade;

        seek additional help in a Java Forum...

        Comment

        Working...
        X