-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatbot.cpp
More file actions
38 lines (31 loc) · 1.25 KB
/
chatbot.cpp
File metadata and controls
38 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input;
cout << "ChatBot: Hello! Welcome to Support Chat.\n";
cout << "ChatBot: Type 'bye' to end the chat.\n";
while (true)
{
cout << "\nYou: ";
getline(cin, input);
// Convert input to lowercase manually for simple keywords
for (char &c : input) c = tolower(c);
if (input == "bye") {
cout << "ChatBot: Thank you! Have a nice day.\n";
break;
} else if (input.find("product") != string::npos) {
cout << "ChatBot: We offer mobiles, laptops, and accessories.";
} else if (input.find("price") != string::npos || input.find("cost") != string::npos) {
cout << "ChatBot: Prices start from ₹5,000. Please specify a product.";
} else if (input.find("support") != string::npos || input.find("help") != string::npos) {
cout << "ChatBot: Call 1800-123-456 or email help@example.com.";
} else if (input.find("warranty") != string::npos) {
cout << "ChatBot: Products have 1-year warranty.";
} else {
cout << "ChatBot: Sorry, I didn't get that.";
}
}
return 0;
}