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
Sentinel loop that repeatedly prompts the user to enter a ... View full answer
Get step-by-step solutions from verified subject matter experts
