Hello,
I coded a text-based game for school, and its about the Bill Of Rights.
Anyway, when the user inputs the amendment number (1-10), based on the given senario, it will tell them if they are right or wrong. If, by mistake, the user inputs something other than an integer, the program freaks out and prints random lines on the screen from the program. Heres a little of the code _______________________________________________________________________
for (;;)
{
int amendselect;
system("cls");
cout << "Thomas, a newspaper reporter, comments in his article" << endl;
cout << "that he hates the president." << endl;
cout << "What amendment protects his action?" << endl;
cout << endl;
cout << "Amendment #:";
cin >> amendselect;
if (amendselect == 1)
{
cout << "Awesome! Obviously you know your first amendment!" << endl;
s = (s + 3);
cout << endl;
cout << endl;
cout << endl;
cout << " ";
system("pause");
break;
}
else
{
system("cls");
cout << "Oops! Heres a hint!" << endl;
cout << endl;
cout << "This amendment also protects your freedom of religion" << endl;
cout << endl;
cout << "Amendment #:";
cin >> amendselect;
if (amendselect == 1)
{
cout << "Great Job! Lets move on!" << endl;
s = (s + 2);
cout << endl;
cout << endl;
cout << endl;
cout << " ";
system("pause");
break;
}
else
{
system("cls");
cout << "Oops! Heres another hint!" << endl;
cout << endl;
cout << "This amendment allows you to assemble peacefully" << endl;
cout << endl;
cout << "Amendment #:";
cin >> amendselect;
if (amendselect == 1)
{
cout << "There you go! Next amendment!" << endl;
s = (s + 1);
cout << endl;
cout << endl;
cout << endl;
cout << " ";
system("pause");
break;
}
else
{
system("cls");
cout << "I cant believe you missed it! That was the 1st amendment!" << endl;
cout << "Here is a good way to remember it:" << endl;
cout << endl;
cout << "R: Religion" << endl;
cout << "A: Assembly" << endl;
cout << "P: Press" << endl;
cout << "P: Petition" << endl;
cout << "S: Speech" << endl;
cout << endl;
cout << endl;
cout << endl;
system("pause");
break;
}
}
}
}
__________________________________________________________________________
Thanks so much for your help, please tell me what the problem is, and not just
some random code that will correct the problem. Thank You!!
-RJ