Ask Question
10 June, 05:49

Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grades in each letter grade defined as follows:

90-100 is an A, 80-89 is a B, 70-79 is a C, 60-69 is a D, 0-59 is an F. Use a negative score as a sentinel to indicate the end of the input. (The negative value is used just to end the loop, do not use it in the calculations). Then output the highest and lowest score, and the average score.

For example if the input is: 72 98 87 50 70 86 85 78 73 72 72 66 63 85 - 1

the output would be:

Total number of grades = 14

Number of As = 1

Number of Bs = 4

Number of Cs = 6

Number of Ds = 2

Number of Fs = 1

The highest score is 98

The lowest score is 50

The average is 75.5

+1
Answers (1)
  1. 10 June, 09:46
    0
    import java. util. Scanner;

    public class Program

    {

    public static void main (String [] Args)

    {

    int totalAGrades = 0, totalBGrades = 0, totalCGrades = 0, totalDGrades = 0, totalFGrades = 0, counter=0, maximum = 0, minimum = 9999, num, total = 0, smallest = 0, largest = 0;

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter exam percentage: ");

    System. out. println ("Enter a negative examScore: ");

    int examScore = in. nextInt ();

    while (examScore > 0)

    {

    counter++;

    if (examScore < 0) {

    break; }

    else if (examScore > maximum) {

    maximum = examScore; }

    else if (examScore < minimum) {

    minimum = examScore; }

    total = total + examScore;

    if (examScore 0)

    smallest = examScore;

    if (examScore > 90 && examScore <=100)

    largest = examScore;

    if (examScore>=90 && examScore<=100)

    totalAGrades++;

    else if (examScore>=80 && examScore<=89)

    totalBGrades++;

    else if (examScore>=70 && examScore<=79)

    totalCGrades++;

    else if (examScore>=60 && examScore<=69)

    totalDGrades++;

    else if (examScore>=0 && examScore<=59)

    totalFGrades++;

    examScore = in. nextInt ();

    }

    System. out. println ("Total number of scores is = " + counter);

    System. out. println ("Total Number of each Letter grade : " + counter);

    System. out. println ("Percentage of total for each letter grade : ");

    System. out. println ("Total number of A grades = " + totalAGrades);

    System. out. println ("Total number of B grades = " + totalBGrades);

    System. out. println ("Total number of C grades = " + totalCGrades);

    System. out. println ("Total number of D grades = " + totalDGrades);

    System. out. println ("Total number of F grades = " + totalFGrades);

    System. out. println ("Lowest exam Score is : "+smallest);

    System. out. println ("Highest exam Score is : "+largest);

    System. out. println ("Average exam Score = " + (total / counter));

    }

    }

    Explanation:

    Get the exam information from user as input and run a while loop until examScore is greater than zero. Use conditional statement to check the scores of students and increment the relevant grade accordingly. Finally display all the information including grades and scores.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grades in each ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers