Question: Write a class Input that contains a main method and public static int readInt(Scanner in, String prompt, String error, int min, int max) readInt displays
Write a class Input that contains a main method and public static int readInt(Scanner in, String prompt, String error, int min, int max)
readInt displays the prompt string, asking the user to enter an int between min and max. If the user enters something not in that range, print the error message and repeat. No prompt, no credit!
Main should call readInt with hard-coded parameters of your choice.
In readInt, don't return the integer until it is validated: keep telling the user to enter an integer in the correct range.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
