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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!