We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 233cb40 commit cf0886eCopy full SHA for cf0886e
1 file changed
chatbot.java
@@ -0,0 +1,17 @@
1
+import java.util.*;
2
+
3
+public class ChatBot {
4
+ public static void main(String[] args) {
5
+ Scanner sc = new Scanner(System.in);
6
7
+ while (true) {
8
+ System.out.print("You: ");
9
+ String msg = sc.nextLine().toLowerCase();
10
11
+ if (msg.contains("hello")) System.out.println("Bot: Hi!");
12
+ else if (msg.contains("how are you")) System.out.println("Bot: I'm fine.");
13
+ else if (msg.contains("bye")) { System.out.println("Bot: Goodbye!"); break; }
14
+ else System.out.println("Bot: Sorry, I don't understand.");
15
+ }
16
17
+}
0 commit comments