Scanner in = new Scanner(System.in);
String err = "\nThat's not a card color!\n\n";
System.out.print("Is your card red, green or blue? ");
String card = in.nextLine();
if ((!"red".equals(card))){
System.out.print(err);
System.exit(0);
}
The user has to input a string that equals either 'red', 'green', or 'blue'. I have it working fine for just 'red', but how do I have it check MULTIPLE strings?
Thank you all! It is now working. Sorry I am kind of new to Java. I tried an else if before but now that the
System.out.print(err);
System.exit(0);
is in an else statement it is working perfectly!