can i get some help?

im making a own "siri" but an else commands messing upp, HELP!
see, i want to make a siri type of thing, it works perfectly, if you type in open google it opens google, whats trending on youtube, and it opens youtube. etc.
but i cant have all the links in the world (or apps).
so i made a command at the end, that says "type in the url or app you wanted to open" and then opens the url / app.
the problem is that after i write in 2 correct commads, it automaticly triggers the else command even though it shouldent.
heres what i did:
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  #include <iostream>
#include <Windows.h>
#include <string>

using namespace std;

int main() 
{	
	//----------------------------------------------------------CMDS
	int cmd = 0;
	//----------------------------------------------------------URLs
	string weather = "https://www.ventusky.com/"; //url
	string blocket = "https://www.blocket.se/"; //url
	string mail = "https://www.outlook.com/"; //url
	string bikroy = "https://www.bikroy.com"; //url
	string google = "www.google.com"; //url
	string facebook = "www.facebook.com"; //url
	string elgiganten = "www.elgiganten.se"; //url
	string netonnet = "www.netonnet.se"; //url
	string jula = "www.jula.se"; // url
	string youtube = "www.youtube.com"; //url
	string microsoft = "www.microsoft.com"; //url
	string paint = "mspaint"; //app
	string extra; // url or app
	//----------------------------------------------------------inputs
	string input = "nothing";
	
	cout << "Hi i am your new assistent, my name is alex\n";
	
	Sleep(2000);
	
	while(true){
			
	cout << "what do you want me to do?" << endl;
	
	getline(cin, input);
	
	cout << "you said " << input << endl;
	
if (input == "open weather" || input == "whats the weather like" || input == "whats the weather like today?"){
	ShellExecute(NULL, "open", weather.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open blocket" || input == "whats new on blocket"){
	ShellExecute(NULL, "open", blocket.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open email" || input =="check my email" || input =="do i have any new mail?" || input =="check my mail" || input =="open mail"){
	ShellExecute(NULL, "open", mail.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open bikroy" || input == "whats new on bikroy?"){
	ShellExecute(NULL, "open", bikroy.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open google" || input == "open a web browser" || input == "open the best web browser"){
	ShellExecute(NULL, "open", google.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open facebook" || input == "whats new on facebook?" || input == "open the most popular social media"){
	ShellExecute(NULL, "open", facebook.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open elgiganten" || input == "whats new on elgiganten?" || input == "whats elgiganten?"){
	ShellExecute(NULL, "open", elgiganten.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open netonnet" || input == "open net on net" || input == "whats new on netonnet?" || input == "whats new on net on net?"){
	ShellExecute(NULL, "open", netonnet.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open jula" || input == "whats new on jula?" || input == "whats newest on jula?"){
	ShellExecute(NULL, "open", jula.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open microsoft" || input == "whats new on microsoft?" || input == "whats the latest windows version?" || input == "whats the newest software?" || input == "whats the newest version of windows?"){
	ShellExecute(NULL, "open", microsoft.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
if (input == "open paint" || input == "open a paint program" || input == "open a program where i can paint" || input == "whats the pre-downloaded paint program?")
	ShellExecute(NULL, "open", paint.c_str(), NULL, NULL, SW_SHOWNORMAL); 

if (input == "open youtube" || input == "whats new on youtube?" || input == "whats trending on youtube?" || input == "whats the best trending on youtube?")
	{ShellExecute(NULL, "open", youtube.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
else {
	cout << "you did something wrong there, please enter the url or app 
        (exactly) you tried to enter" << endl;
	getline(cin, extra);
	ShellExecute(NULL, "open", extra.c_str(), NULL, NULL, SW_SHOWNORMAL);
	break;
}

} //while

}// int main


HELP!!!!!
Last edited on
1
2
3
4
5
6
7
8
9
10
if (input == "open youtube" || input == "whats new on youtube?" || input == "whats trending on youtube?" || input == "whats the best trending on youtube?")
	{ShellExecute(NULL, "open", youtube.c_str(), NULL, NULL, SW_SHOWNORMAL); 
}
else {
	cout << "you did something wrong there, please enter the url or app 
        (exactly) you tried to enter" << endl;
	getline(cin, extra);
	ShellExecute(NULL, "open", extra.c_str(), NULL, NULL, SW_SHOWNORMAL);
	break;
}


Either the IF block, or the ELSE block, will happen. That's how an IF-ELSE block works. What do you type in that you think SHOUDN'T enter the ELSE block?
ok, but what can i enter in the if else command?
ex. if else (???){
blablabla
}
because it has to be an easier method then typing in all the if input != "bla" because i have like 50 of those commands, help?
bool commandWasRecognised = false; near the top.

1
2
3
4
if (commandWasRecognised  == false)
{
  // didn't recognise the command. Tell user
}
at the end.

You work out what to do in the middle.

Welcome to programming. This is programming. Thinking about the problem at hand in such a way that your solution has a programattic expression. All the rest is just memorising syntax. This is programming. Thinking.

ok i got it, i just had the first if as if, and then all others as else if ant it worked!
thanks btw, i was suspecios about if it would work but now i have no doubt!!!!
Topic archived. No new replies allowed.