#include "g:\victor\vitodef.h" void main(void) { // ***** Ron Sinclair // ***** assignment #3: Multiplication Tester, level 2 randomize(); clrscr(); // ***** declarations int number1, number2, computeranswer, kidanswer, numprobs, count=0; int rightanswers=0, wronganswers=0, chances; char kidsname[20]; cout << "what is your name?\n"; cin >> kidsname; cout << kidsname << ", how many problems would you like to attempt?\n"; cin >> numprobs; while (numprobs != count) { number1=random(13); number2=random(13); cout << endl << kidsname << " , what is " << number1 << " times "; cout << number2 << "?\n"; cin >> kidanswer; computeranswer = number1 * number2; //RIGHT ANSWER SECTION if (kidanswer == computeranswer) { cout << "RIGHT, " << kidsname << " !!" << endl; rightanswers++; } //WRONG ANSWER SECTION if (kidanswer != computeranswer) { cout << endl << "WRONG, " << kidsname << " !!" << endl; chances=0; chances++; while ((kidanswer != computeranswer) and (chances < 3)) { cout << endl << "WRONG, " << kidsname << ", what is "; cout << number1 << " times " << number2 << "?\n"; cin >> kidanswer; chances++; } if (kidanswer == computeranswer) { cout << endl << "RIGHT, " << kidsname; rightanswers++; } else { cout << endl << "The corect answer is "<< computeranswer; cout << endl; wronganswers++; } } count++; } cout << endl; cout << kidsname << ", your score is: " << rightanswers << " problems "; cout << "right, and " << wronganswers << " wrong."; getche(); }