Answer:
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 <= 50 && 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.