#include <iostream>
#include <ctime>
using namespace std;
int main() {
int answer;
string question;
string play = "";
srand(time(NULL));
cout << "What question would you like to ask the Magic 8 ball?: \n";
cout << "\n";
cin >> question;
answer = rand () % 8 + 1;
if (answer == 1) {
cout << "The answer is: It is certain\n";
} else if (answer == 2) {
cout << "The answer is: It is decidely so\n";
} else if (answer == 3) {
cout << "The answer is: Most likely\n";
} else if (answer == 4) {
cout << "The answer is: Signs point to yes\n";
} else if (answer == 5) {
cout << "The answer is: Ask again later\n";
} else if (answer == 6) {
cout << "The answer is: Don't count on it\n";
} else if (answer == 7) {
cout << "The answer is: My sources say no\n";
} else {
cout << "The answer is: Reply hazy, try again\n";
}
cout << "Would you like to play again?(y/n): ";
cin >> play;
if (play == "yes" || play == "y") {
cin >> question;
} else if (play == "no" || play == "n") {
cout << "Thank you for playing with the Magic 8 Ball";
}
return 0;
}
It stops the program after it gives my answer, not letting the user answer if they want to play again or not. Please help me, I've been stuck on this for a while now and don't know what to do.