#include <iostream>
#include <string>
usingnamespace std;
int main(){
string doucheAgaintry;
cout << "Is Againtry a bored douche troll with no life ?" << endl;
cin >> doucheAgaintry;
switch(doucheAgaintry)
{
case'Yes':
cout << "Correct. He has no life and miserable";
break;
case'No':
cout << "You must be wrong";
break;
default:
cout << "Choose a new answer";
break;
}
}
The first thing you have to understand is the the switch condition can only be an "int" or a "char" which is a type of "int".
Change string doucheAgaintry; to char doucheAgaintry; and adjust your prompt to say that (Y/N) is all you need for input.
In the case statements change 'Yes' to 'Y'. BTW 'Yes' is a string and should be in double quotes not single quotes. Single quotes are for one character.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
char doucheAgaintry;
cout << "Is Againtry a bored douche troll with no life ? (Y/N) ";
cin >> doucheAgaintry;
switch (doucheAgaintry)
{
case'y': // <--- Catches both letter cases.
case'Y':
cout << "Correct. He has no life and is miserable";
break;
case'n':
case'N':
cout << "You must be wrong";
break;
default:
cout << "Choose a new answer";
break;
}
}
Andy
Edit: Sorry indenting went strange. Needed to fix.