I am making an A.I that carries on a conversation with you. when you run the program, the computer says hi, and the user can enter multiple greetings back (like you, howdy etc.)
my question is when the computer asks the user "How are you?" and the user answers. I programmed a switch where if you say something like "good" the computer will reply "Glad to hear it." , but it doesn't. what did I Do wrong?
here is my code:
System.out.println("hi");
Thread.sleep(3000);
System.out.println("The computer would like to remind you to reply with only a greeting");
Scanner rexy = new Scanner(System.in);
String domino = rexy.nextLine();
switch (domino){
case "hello":
System.out.println("How are you?");
break;
case "hi":
System.out.println("How are you?");
break;
case "howdy":
System.out.println("How are you?");
break;
case "heyo":
System.out.println("How are you?");
break;
case "hello?":
System.out.println("How are you?");
break;
case "hey":
System.out.println("How are you?");
break;
case "sup":
System.out.println("How are you?");
break;
case "good":
System.out.println("Glad to hear it");
break;
case "great":
System.out.println("Glad to hear it");
break;
case "awesome":
System.out.println("Glad to hear it");
break;
case "splendid":
System.out.println("Glad to hear it");
break;
case "fantastic":
System.out.println("Glad to hear it");
break;
case "fine":
System.out.println("Glad to hear it");
break;
case "what's crackalakin?":
System.out.println("How are you?");
break;
case "what's up turd face?":
System.out.println("That's rude! How are you?");
break;
}
}
}
thanks.
java 7. Good morning :)println()statement over and over.rexy.nextLine().toLowerCase()orswitch(domino.toLowerCase())so that thedominoString can match up with any of thecasestatements regardless of case.