Question: 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

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

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!