Pretty much, whenever I try to run the code, the result is a negative before it asks for the color prompt. I don’t know why, when I run the color question standalone it works fine. It’s only in this code, any pointers?
Welcome to my twisted little game, are you little flubbers ready to engage in some games? Y=yes, N=no.
Y
Happy to hear it!
First question, here we go!
What is the best color?
NOPE WRONG ANSWER! TRY AGAIN SILLY!
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Put variables below this
char guess12;
// Opening question
cout << "Welcome to my twisted little game, are you little flubbers ready to engage in some games? Y=yes, N=no." << endl;
cin >> guess12;
if(guess12 == 'Y'||'y')
cout << "Happy to hear it!" << endl;
else
cout << "Oh well, we continue anyways. Not like you have much of a choice." << endl;
string color;
// Color question
cout << "First question, here we go!n"
<< "What is the best color?" << endl;
getline(cin, color);
while(color != "Purple" && color != "purple")
{
cout << "NOPE WRONG ANSWER! TRY AGAIN SILLY!n";
getline(cin, color);
}
cout<< "Well done! Purple is the best color!n";
}
I have tried swapping the order, finding alternatives to get the answer, and even trying to fit it into another function. I think I’m just missing something and I need help.
Adam Odens MidnightAJO is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.