Question: Write a sentinel loop that repeatedly prompts the user to enter a number and, once the number 1 is typed, displays the maximum and minimum

Write a sentinel loop that repeatedly prompts the user to enter a number and, once the number –1 is typed, displays the maximum and minimum numbers that the user entered. Here is a sample dialogue:

Type a number (or –1 to stop): 5
Type a number (or –1 to stop): 2
Type a number (or –1 to stop): 17
Type a number (or –1 to stop): 8
Type a number (or –1 to stop): –1
Maximum was 17
Minimum was 2

If –1 is the first number typed, no maximum or minimum should be printed. In this case, the dialogue would look like this:

Type a number (or –1 to stop): –1

Step by Step Solution

3.35 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sentinel loop that repeatedly prompts the user to enter a ... View full answer

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 Building Java Programs A Back to Basics Approach Questions!