I am trying to have my user input not crash my program by restricting what the user can input such as:
See dasblinkenlight's awnser with the NumberFormatException catch. I was thinking of doing that. This also works too:
You need to combine the two loops like so:
while(true) {
if(!sc.hasNextInt) {
System.out.println("Only Integers!");
continue;
}
choose = sc.nextInt();
if(choose <= 0) {
System.out.println("The number you entered was too small.");
continue;
} else if(choose > 30) {
System.out.println("The number you entered was too large.\nMax: 30");
continue;
}
break;
}
sc.close();