The program asks the user questions and responds accordingly. I am using ArrayLists with if statements to accomplish this. I cannot understand why my else/if code is not working. When I respond with "North Carolina" I always receive the final response of "I would have never guessed!"
System.out.print("Where are you from? ");
states.add(scanner.next());
if (states.contains("Florida") || states.contains("florida")) {
System.out.println("So was I!\n");
} else {
if (states.contains("North Carolina") || states.contains("north carolina")) {
System.out.println("I hear that's a nice place to live.\n");
} else {
System.out.println("I would have never guessed!");
}
}
Aucun commentaire:
Enregistrer un commentaire