Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

=+4. Invent other options and explain.

Answered: 1 week ago