#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, hifactor, grade; char kidsname[20]; cout << "what is your name?\n"; cin >> kidsname; cout << kidsname << ", how many problems would you like to attempt?\n"; cin >> numprobs; //HIGHEST FACTOR SECTION cout << kidsname << ", what's the highest factor you wish to use?\n"; cin >> hifactor; hifactor++; while (numprobs != count) { number1=random(hifactor); number2=random(hifactor); 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 << "**********************************************\n"; //GRADING SECTION grade=rightanswers * (100/numprobs); if ((grade >= 90) and (grade <= 100)) cout << kidsname << ", your grade is an A -- " << grade << endl; else if ((grade >= 79) and (grade <= 89)) cout << kidsname << ", your grade is a B -- " << grade << endl; else if ((grade >= 69) and (grade <= 88)) cout << kidsname << ", your grade is a C -- " << grade << endl; else if ((grade >= 58) and (grade <= 68)) cout << kidsname << ", your grade is a D -- " << grade << endl; else cout << kidsname << ", your grade is an F -- " << grade << endl; cout << kidsname << ", your score is: " << rightanswers << " problems "; cout << "right, and " << wronganswers << " wrong.\n"; cout << "**********************************************\n"; getche(); }