public static int getIntegerBetween(int min, int max) {
int value = 0;
do {
try {
value = Integer.parseInt(input.nextLine());
}
catch (Exception e) {
System.out.printf("Error! Please re-enter value [%d-%d]:\n", min, max);
continue;
}
} while (value < min || value > max);
return value;
}