0
System.out.println("What color are your eyes?");    
Scanner question2 = new Scanner(System.in);
String eye_color = question2.nextLine();
if(eye_color.equals("green", "blue", "hazel", "brown", "amber")) {
    System.out.println("So pretty!");
}
else {
    System.out.println("Yeah right, what are you, an alien or something?");
}

i'd like the user input to not be bound by case, example: "Green" vs "green". Is there a way I can accomplish this? Or would I have to use a different method.

  • 1
    i guess this is java, not javascript? – inarilo Aug 26 '17 at 22:47
  • yes thanks for finding the dupe, i chose to use the || method, however i'd like the user input to not be bound by case, example: "Green" vs "green". Is there a way I can accomplish this? Or would I have to use a different method. – Jess Watson Aug 26 '17 at 23:07
  • Use the **eye_color.equalsIgnoreCase()** method to ignore letter case. Or of course: `if (eye_color.toLowerCase().matches("green|blue|hazel|brown|amber")) {....}` – DevilsHnd - 退職した Aug 27 '17 at 00:02

0 Answers0