Question
Prompts the user for a value by displaying prompt. * Note: This method should not add a new line to the output of prompt. *
Prompts the user for a value by displaying prompt. * Note: This method should not add a new line to the output of prompt. * * After prompting the user, the method will consume an entire * line of input while reading an int. Leading whitespace is ignored. * If the value read is between min and max * (inclusive), that value is returned. Otherwise, output * "Expected value between 0 and 10." * where 0 and 10 are the values in the min and max parameters, respectively. * Invalid input may be non-integer in which case the same error message is * displayed and the user is prompted again. * * Note: This is a general purpose method to prompt for, read and validate an int * within the min and max. This method should be tested for any min and max. * * @param input The Scanner instance to read from System.in. * @param prompt Output to the user. * @param min The minimum acceptable int value (inclusive). * @param min The maximum acceptable int value (inclusive). * @return Returns the value read from the user. */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started