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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!