Question
Need to fix c++ program : magic 8 ball.continue(y/n) not working. { int result; char play; string quest; cout < < Do you like to
Need to fix c++ program :
magic 8 ball.continue(y/n) not working.
{ int result; char play;
string quest;
cout<< "Do you like to play(Y/N)"; cin >> play; if (play != 'N' || play != 'n') {
cout << " Ask a Question : ";
getline(cin, quest);
result = rand() % 8;
string ans;
if (result == 1) { ans = "Yes, definetely."; } else if (result == 2) { ans = "Yeah, it's possible."; } else if (result == 3) { ans = "I think so."; } else if (result == 4) { ans = "Yes, but not easily."; } else if (result == 5) { ans = "If you work hard."; } else if (result == 6) { ans = "Yes."; } else if (result == 7) { ans = "No."; } else if (result == 8) { ans = "I wouldn't do it."; }
else { ans = "Error"; }
cout << " " << ans << " "; } else { cout << " Would you like to continue? (Y/N): "; cin >> play;
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started