All pastes #815484 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-14 02:53 UTC
rendered paste body
int AdditionLawl(int &addition)
/* Displays random addition problems */

{
	int answer;
	double score;
	score = 0;

	randomize();

	int n1 = (random(100) + 1);
	int n2 = (random(100) + 1);

	cout << "\n \t" << n1 << " + " << n2 << " = ";
	cin >> answer;

	if (answer == n1 + n2) {
	cout << "\t" << "CORRECT" << endl;
	score+=10;
	}
		else if (answer != n1 + n2) {
				cout << "\t" << "WRONG Try again" << endl;
				cout << "\n \t" << n1 << " + " << n2 << " = ";
					cin >> answer;
			}
		if (answer == n1 + n2) {
			cout << "\t" << "CORRECT" << endl;
			score+=5;
		}
		else if (answer != n1 + n2) {
				cout << "\t" << "WRONG Try again" << endl;
				cout << "\n \t" << n1 << " + " << n2 << " = ";
					cin >> answer;
		}
		if (answer == n1 + n2) {
			cout << "\t" << "CORRECT" << endl;
			score+=2;
		}
		else if (answer != n1 + n2) {
				cout << "\t" << "You've been wrong 3 times. The answer is " << n1 + n2 << endl;
		}
		cout << score;
		return(answer);
}