rendered paste body{
int answer;
int right;
right = 0;
int tries;
tries = 0;
double score;
score = 0;
randomize();
int n1 = (random(100) + 1);
int n2 = (random(100) + 1);
cout << "\n \t" << n1 << " + " << n2 << " = ";
while((right != 1) && (tries < 3)) {
cin >> answer;
if (answer == n1 + n2) {
cout << "\t" << "CORRECT" << endl;
right = 1;
tries = 0;
}
else if (answer != n1 + n2) {
cout << "\t" << "WRONG Try again" << endl;
cout << "\n \t" << n1 << " + " << n2 << " = ";
cin >> answer;
right = 0;
tries = 1;
}
if (answer == n1 + n2) {
cout << "\t" << "CORRECT" << endl;
right = 1;
}
else if (answer != n1 + n2) {
cout << "\t" << "WRONG Try again" << endl;
cout << "\n \t" << n1 << " + " << n2 << " = ";
cin >> answer;
right = 0;
tries = 2;
}
if (answer == n1 + n2) {
cout << "\t" << "CORRECT" << endl;
right = 1;
}
else if (answer != n1 + n2) {
cout << "\t" << "You've been wrong 3 times. The answer is " << n1 + n2 << endl;
tries = 3;
}
}
return(answer);
}
MAIN
int main()
{
int choice;
int answer;
cout << "Enter the number for the problem type desired." << endl;
cout << "\t 1. Addition \n" << "\t 2. Subtraction \n" << "\t 3. Multiplication \n";
cout << "\nEnter choice: ";
cin >> choice;
for (int i = 0; i <= 10; i++)
if (choice == 1) {
AdditionLawl(answer);
}
else if (choice == 2) {
MinusLawl(answer);
}
else if (choice == 3) {
TimesLawl(answer);
}
return(0);
}