Answer to Question #265408 in Java | JSP | JSF for Pongzss

Question #265408

Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, 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.

1
Expert's answer
2021-11-13T23:54:05-0500
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner input=new Scanner(System.in);
	    int total = 0;
        int count = 0;


while (true){
    System.out.println("Enter student test score: ");
    int N=input.nextInt();
    if (N == 999){
        break;}
    
    else if( N < 0 || N > 100){
        System.out.println("Number is incorrect");
}
    else{
        total += N;
        count += 1;}
}
double avg = total / count;
System.out.println("The average is:"+ avg);
System.out.println("There were " +count + " numbers entered");
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS