- Write a method
public static int readInt(String prompt, int min, int max)
that displays the prompt string, read an integer and testswhether it is between the minimum and maximum. If not, print anerror message and repeat reading the input. Also, if the usercancels the input dialog, print an error message and keep reading.Add the method to an appropriate class and provide a testprogram.
Expert Answer
Answer to Write a method public static int readInt(String prompt, int min, int max) that displays the prompt string, read an inte…