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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started