Need help with exception handling for a string
I am writing a program that you have to enter either "R", "T", or "C" for some code to execute. I have everything running but cannot figure out how to handle if a different letter is entered or a number.....I want a reenter message to print and do again. I know how to use the numberFormat exception, but don't know how a string exception would be coded. Do I have to make my own? I tried using if statements, but that doesn't work. Heres the if's I had:
//get input from the user
System.out.println("Enter customer type (r/c/t): ");
System.out.println();
customerType = sc.next();
//check for non r/t/c entry
if(!customerType.equalsIgnoreCase("R")){
if(!customerType.equalsIgnoreCase("T"))
if(!customerType.equalsIgnoreCase("C"))
System.out.println("Re-enter");
}else{
System.out.println("Enter subtotal: ");
System.out.println();
double subtotal = sc.nextDouble();
this only works for R entry.