Question

Write application that allows a user to enter any number of student...

Write application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entered is less than 0 or more than 10, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as QuizScoreStatistics.java.

Answer & Explanation
Verified Solved by verified expert

The following is a program in Java programming language.

 

Step-by-step explanation

The following is a program in Java programming language.

 

import java.util.*;

public class QuizScoreStatistics

 {

   public static void main(String args[]) 

{
       Scanner in = new Scanner(System.in);
       int score, scoreCount = 0, highestScore = 0, lowestScore = 0, arithmeticAverage = 0;
       while (true) 

{
           System.out.print("Enter a score(0 to 10): ");
           score = in.nextInt();
           if (score == 99) break;
           if (score >= 0 && score <= 10) {
               if (scoreCount == 0 || score > highestScore) highestScore = score;
               if (scoreCount == 0 || score < lowestScore) lowestScore = score;
               arithmeticAverage += score;
               scoreCount++;
           } 

else

 {
               System.out.println("Score must be between 10 and 0");
           }
       }
       System.out.print("Number of valid scores: ");
       System.out.println(scoreCount);
       System.out.print("The highest score: ");
       System.out.println(highestScore);
       System.out.print("The lowest score: ");
       System.out.println(lowestScore);
       System.out.print("The average of scores: ");
       System.out.println(arithmeticAverage / (double) scoreCount);
   }
}