Question: import java.util.Scanner ; public class FirstProg { public static void main( String args[]) { Scanner scanner = new Scanner( System .in); System .out.print(Enter number of

import java.util.Scanner; public class FirstProg { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); System.out.print("Enter number of tests: "); int n = scanner.nextInt(); int i = 0, temp; double avg = 0; while(iSystem.out.print("Enter test score #"+(i+1)+": "); temp = scanner.nextInt(); if(temp>=0 && temp<=100){ i++; avg += temp; } else { System.out.println("Invalid test score"); continue; } } avg = avg/n; System.out.println("Total number of test scores: "+n); System.out.printf("Average of all test scores: %.2f",(avg)); } }

How can I make it to were there can only be a max of 100 grades to be averaged. So if someone entered 105 in the first line, it would make them retry until it was between 1 and 100.

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!