logo Practice-It logo

BJP5 Self-Check 5.13: sentinelMinMax

Language/Type: Java do/while fencepost input Scanner
Author: Marty Stepp (on 2019/09/19)

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
Type your solution here:

This problem asks for bare code. Submit a fragment of Java code as described. Do not write any class or method heading around your code; just write the lines of code that will produce the result described.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.