CJCoding With Joseph
15free / daySign inCreate account

Create an inputIntRange() method that accepts a Scanner, min, and max value. It should: 1. Call inputInt() to get a valid integer (you can assume this method exists) 2. Check if the value is between min and max (inclusive) 3. If not, print "Value must be between [min] and [max]: " and try again 4. Return the valid value

In main(), use it to get a number between 0 and 10, then display:

You entered: [number]

Example: If user enters 15, then -5, then 7, output shows errors for first 2 then prints the output shown in Expected Output.

⚠️ IMPORTANT - AUTO-INPUT MODE: This question uses automated input testing. When you run your code, the input stream will AUTOMATICALLY contain: '7\n'

DO NOT wait for manual keyboard input - Scanner will read from the pre-filled buffer stream immediately. Your inputInt() method should use scanner.nextLine() to read input.

Think of it like Eclipse/VS Code but with the input already typed in and waiting for your Scanner to read it.

Expected output

You entered: 7

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
User Input
Auto-input
7\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.