Question

Write a java program to read a list of exam grades given as int's in the...

Write a java program to read a list of exam grades given as int's in the range of 0 to 100. Your program will display the total number of grades and the number of grades in each letter-grade category as follows:

A
93 <= grade <= 100
A-
90 <= grade < 93
B+
87 <= grade < 90
B
83 <= grade < 87
B-
80 <= grade < 83
C+
77 <= grade < 80
C
73 <= grade < 77
C-
70 <= grade < 73
D
60 <= grade < 70
F
0 <= grade < 60
Use a negative number as a sentinel value to indicate the end of the input. (The negative value is used only to end the loop, do not use it in your calculations.)

Each time you prompt the user to enter a grade you will print:

Enter a grade:
  
For example, if the input is:

98 95 87 86 83 92 85 78 74 72 81 71 69 63 50 43 -1
  
The output would be:

Total number of grades = 16
Number of A's = 2
Number of A-'s = 1
Number of B+'s = 1
Number of B's = 3
Number of B-'s = 1
Number of C+'s = 1
Number of C's = 1
Number of C-'s = 2
Number of D's = 2
Number of F's = 2
  
Please note that your class should be named Grades
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import java.util.Scanner;   //importing scanner class for input purpose
public class Grades
{
   public static void main (String args[])
       {
           Scanner input=new Scanner(System.in);   
           int countGrades[]=new int []{0,0,0,0,0,0,0,0,0,0}; //declare array and intialize each with zero
           System.out.print("Enter a grade:");
           int grade=input.nextInt();   //asking user to enter the grade
           int total_count=0;
           while (grade>0)
               {
               total_count++;
               if (grade>=93 && grade<= 100)                   //based on the marks increment the particular index count
                   countGrades[0]++;
               else if (grade>=90 && grade < 93)
                   countGrades[1]++;
               else if (grade >=87 && grade < 90)
                   countGrades[2]++;
               else if (grade>=83 && grade < 87)
                   countGrades[3]++;
               else if (grade>=80 && grade < 83)
                   countGrades[4]++;
               else if (grade>=77 && grade < 80)
                   countGrades[5]++;
               else if (grade>=73 && grade < 77)
                   countGrades[6]++;
               else if (grade>=70 && grade < 73)
                   countGrades[7]++;
               else if (grade>=60 && grade < 70)
                   countGrades[8]++;
               else if (grade>=0 && grade < 60 )
                   countGrades[9]++;
               System.out.print("Enter a grade:");
               grade=input.nextInt();             //take input from user untill user enters negative
               }
           System.out.println("Total number of grades = " +total_count); //finally printing total_count
           System.out.println("Number of A's = " +countGrades[0]);
           System.out.println("Number of A-'s = " +countGrades[1]);
           System.out.println("Number of B+'s = " +countGrades[2]);
           System.out.println("Number of B's = " +countGrades[3]);      //printing each grade count from countGrades() Array
           System.out.println("Number of B-'s = " +countGrades[4]);
           System.out.println("Number of C+'s = " +countGrades[5]);
           System.out.println("Number of C's = " +countGrades[6]);
           System.out.println("Number of C-'s = " +countGrades[7]);
           System.out.println("Number of D's = " +countGrades[8]);
           System.out.println("Number of F's = " +countGrades[9]);
   }
}

Code and Output:

Note : if you have any queries please post a comment thanks a lot..always available to help you..

Add a comment
Know the answer?
Add Answer to:
Write a java program to read a list of exam grades given as int's in the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This program has to be made in java also will but uploaded on zybooks Write a...

    This program has to be made in java also will but uploaded on zybooks Write a program in Java to read a list of exam grades given as int's in the range of 0 to 100. Your program will display the total number of grades and the number of grades in each letter-grade category as follows: A 93 <= grade <= 100 A- 90 <= grade < 93 B+ 87 <= grade < 90 B 83 <= grade < 87...

  • write a program that uses a function to read in the grades for four classes and...

    write a program that uses a function to read in the grades for four classes and then uses a function to calculate the average grade in each of the classes. input the grades for one student. we will name her Beverly. output how Beverly's grade differs from each classe average. Make sure that your output is very clear. Below is your data: English 90 70 85 45 95 95 82 97 99 65 History 63 94 60 76 83 98...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1...

    Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...

  • Student average array program

    Having a bit of trouble in my c++ class, was wondering if anyone can help.Write a program to calculate students' average test scores and their grades. You may assume the following input data:Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 68 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72...

  • A statistics teacher predicts that the distribution of grades on the final exam will be 25%...

    A statistics teacher predicts that the distribution of grades on the final exam will be 25% A's, 30% B's, 35% C's, and 10% D's. The actual distribution of grades on the final exam for 20 students is as follows. Using a 0.05 level of significance, is the statistics teacher's prediction correct? Number Grade of Students 16 P B un IC 16 D 3 Question 38 (2.63 points) Which test are you running? ANOVA One mean zetest c Chesquare Goodness of...

  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

  • Write down a Cre program on computer that calculates the grades of the stud f the...

    Write down a Cre program on computer that calculates the grades of the stud f the students for the marks by using "if else statements "for the following conditions. Marks 60 Grade "D" Marks > 60 &&70 Grade "C" Marks > 70 &&80 Grade "B" Marks > 80 && 90 Grade "A" Marks> 90 && -100 Grade "A+"

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT