//Cameron Pham CS1A Chapter 3, P. 146, #15
//
/*******************************************************************************
*
* Generate Random Addition Problems
* _____________________________________________________________________________
*
* This program acts as a math tutor for a young student. It generates two
* random numbers, pauses while the student solves it, and then displays the
* correct answer.
*
******************************************************************************/
#include <iostream>
#include <cstdlib> // Allows for usage of rand() and srand()
#include <ctime> // Allows for usage of time()
using namespace std;
int main()
{
// Seed the random number generator and use the current time to make the
// numbers different each time the program is run.
srand(static_cast <unsigned int> (time(0)));
// Generate two random numbers between 100 and 999
int number1 = rand() % 900 + 100;
int number2 = rand() % 900 + 100;
// Calculate the correct answer.
int answer = number1 + number2;
// Display the addition problem.
cout << "Hi! I'm your personal 'Math Tutor'." << endl;
cout << "Solve the following addition problem:" << endl;
cout << " " << number1 << endl;
cout << "+ " << number2 << endl;
cout << "---------" << endl;
// Pause the program so the student has time to solve the problem.
system("pause");
// Display the correct solution.
cout << endl;
cout << "The correct answer is:" << endl;
cout << " " << number1 << endl;
cout << "+ " << number2 << endl;
cout << "---------" << endl;
cout << " " << answer << endl;
return 0;
}