Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored 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