Skip to content

Commit cf0886e

Browse files
chatbot.java
1 parent 233cb40 commit cf0886e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

chatbot.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)