Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

5. Arranging for the training facility and room.

Answered: 1 week ago

Question

1. Discuss the five types of learner outcomes.

Answered: 1 week ago