Question: Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99 . If the

Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.

Example: Input -

9 12 7 -4 4 6 99

Expected output:

4

9

4

6.5

Score must be between 10 and 0

-----------------------------------------------------------

This is the code I have but it is not 100% correct:

import java.util.*;

public class QuizScoreStatistics {

public static void main (String args[]) { Scanner in = new Scanner(System.in); int score, count = 0, highest = 0, lowest = 10, average = 0; while (true) { System.out.print("Enter a score: "); score = in.nextInt(); if (score == 99) break; if (score >= 0 && score <= 10) { if (score > highest) highest = score; if (score < lowest) lowest = score; average ++; count ++; } } { System.out.println("number of valid scores = " + count); System.out.println("highest score is " + highest); System.out.println("lowest score is " + lowest); System.out.println("average score is " + (average/count)); } { System.out.println("Highest score: " + highest); System.out.println("Lowest score: " + lowest); System.out.println("Average score: " + (average/ count)); } }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!