Question: Write a JAVA program to read in positive integers until a negative value is entered, then it processes the values except for the last negative

Write a JAVA program to read in positive integers until a negative value is entered, then it processes the values except for the last negative value and displays the largest value, smallest value, and the average of the entire values.

Ex)

Output:

Please enter a positive integer, or -1 to quit.

Input: 1

Output:

Please enter a positive integer, or -1 to quit.

Input: 2

Output:

Please enter a positive integer, or -1 to quit.

Input: 3

Output:

Please enter a positive integer, or -1 to quit.

Input: 4

Output:

Please enter a positive integer, or -1 to quit.

Input: -1

Output:

For the 4 numbers you entered

the largest value = 4

the smallest value = 1

and the average is = 2.5

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!