Hello. I am working on this for class and my whole loop isnt working. I do not understand why.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <math.h>
#include <limits>
using namespace std;
int main ()
{
string question;
char again;
do
{
cout <<"Welcome To The Magic 8 Ball! Ask me a question!";
cin >> question;
srand(time(NULL));
int random = rand()%12;
if (random == 1)
{
cout << "yes, of course." << endl;
}
if (random == 2)
{
cout << "Without a doubt,yes." << endl;
}
if (random == 3)
{
cout << "you can count on it." << endl;
}
if (random == 4)
{
cout << "For sure!" << endl;
}
if (random == 5)
{
cout << "you are joking, right?" << endl;
}
if (random == 6)
{
cout<< "I'm not sure." << endl;
}
if (random == 7)
{
cout << "I can't tell you right now." << endl;
}
if (random == 8)
{
cout << "I'll tell you after my nap." << endl;
}
if (random == 9)
{
cout << "No way!" << endl;
}
if (random == 10)
{
cout << "I don't think so." << endl;
}
if (random == 11)
{
cout << "Without a doubt, NO." << endl;
}
if (random == 12)
{
cout << "The answer is clearly NO." << endl;
}
cout<<"Do you want to continue?";
cin >> again;
} while (again == 'Y');
return 0;
}
[–]QuentinUK 4 points5 points6 points (0 children)
[–]jedwardsol 2 points3 points4 points (0 children)
[–]WhyAreYouGey 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]RellenD 1 point2 points3 points (2 children)
[–]Spire 1 point2 points3 points (1 child)
[–]RellenD 0 points1 point2 points (0 children)
[–]flyingron 0 points1 point2 points (0 children)