## Math Tutor Enhanced

4.9: This is a modification of Chapter 3′s Problem 15, which was:

Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as

```   247
+ 129
------
```

The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution, for example:

```   247
+ 129
------
376
```

This time, write a program that can be used as a math tutor for a young student. The program should display two random numbers that are to be added. The program should wait for the student to enter the answer. If the answer is correct, a message of congratulations should be printed. If the answer is incorrect, a message should be printed showing the correct answer.

My solution:

```/* Chapter 4 Challenge 9
Written by Kirk Hingsberger
October 3, 2007
Math Tutor - Enhanced
*/

#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;

int main()
{
char ch;
srand(time(0));
const int SEED = 999;

num1 = 1 + rand() % SEED;
num2 = 1 + rand() % SEED;

cout << setw(5) << num1 << endl;
cout << "+ " << setw(3) << num2 << endl;
cout << "_____" << endl;
num3 = num1 + num2;
cin.get(ch);

cout << setw(5) << num3 << " is the correct answer, ";

{
cout << "great job!" << endl;
}
{
}
else
{
}

return 0;
}
```

Note: This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled “Making Decisions”.

I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.

### 2 Responses to “Math Tutor Enhanced”

1. You have a great site here. Questions.

I’m an online student in Programming I. Are you a programmer?

\$4.95 a month for this site? And how hard was it to set up.