Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PrintAverage.java WWrite a class named PrintAverage The main method of the class should only contain a call to a void method named userlnterfacell which takes
PrintAverage.java WWrite a class named PrintAverage The main method of the class should only contain a call to a void method named userlnterfacell which takes no parameters The userlnterface) method must use a sentinel loop to repeatedly prompt the user for integers If the user enters anything other than an integer, display a new prompt that says "Not an integer, try again: (use a while loop and the Scanner hasNext!nt() method for this! Once the user types any negative number (sentinel), the method should display the average of all the non-negative numbers typed Display the average as a double. Assume inputs do not contain spaces Here is a sample dialogue with the user: csc$ java PrintAverage Type an integer (negative number to quit): 4 Type an integer (negative number to quit): i Not an integer, try again: L Not an integer, try again: % Not an integer, try again: 7 Type an integer (negative number to quit): 16 Type an integer (negative number to quit): -8 Average was 9.6e csc$ If the first number that the user types is negative (count of non-negative integers entered is 0), do not print an average Sample user dialog for this case csc$ java PrintAverage Type an integer (negative number to quit): -2 csc$
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