I was trying to set my program up that prompts the user to enter the values y
or n
into a string called resetValue
which I try
to pass the value as char r
. I know there is some errors with the code but I am curious what the error code should be for my catch
statement should be. If the user enters an invalid value other than y
or n
. I was just looking through a list of errors on Oracle website but there are so many I don't know which one is the best fit for this problem.
// Prompts the user to reset the program from the beginning if they wish
while(true){
System.out.print("\nWould you like to enter some new numbers? Type (y) or (n): ");
resetValue = input.readLine();
try {
char r = resetValue.charAt(0);
if( r == y || r == Y ){
break;
}
else if( r == n || r == N){
reset = true;
break;
}
}
catch (ERROR STATUS HERE) {
System.out.print("Please type either (y) or (n) on the keyboard.");
}
}