UMBC CMSC104 CSEE | CMSC104 | Lectures | news | help

# Project 2: Math Tutor

## Requirements Specification

Write a program, using at least six function (specified below) that will help young students improve their math skills. The program will start by presenting the user with a cleared screen, and a menu that will list the choices for the user:

CMSC104 Tutor

1. Display Instructions
3. Subtraction Problems
4. Multiplication Problems
5. Division Problems
6. Exit Program

If the user selects item 1, display a set of instructions to the user about how to use your program. You are to create those instructions, as you think will best help the user.

When the user selects items 2 through 5, the program will:

Clear the screen, and then present a set of five problems to the user, one at a time.

If the user answers the question correctly on the first try, the program must count that questions as correctly answered and give a message to the user (Something like "That is correct!! Good work!". Otherwise, the user will be told that the answer was wrong and that it was either too high or too low. The user must then try the same problem again until they get it right (but don't count as one correct answer.)

You must also show the problem number (number for the entire session), and the total number of correct answers, as well as the percentage of correct answers.

All problems will be created using the random number generator rand(), as shown in the lecture notes. The values must be in the range of 1 to 10. (For division, the answer must be an integer in the range of 1 to 10. For subtraction, the answer can not be a negative number.)

You do not have to seed the random number generator, but if you do, I suggest you use the time function (time.h) results for the seed:

srand( time( NULL ) );

If the user selects item 6, the program will be finished and terminate.

## Notes

To clear the screen, use the system() function (stdlib.h) with the string argument of "clear":

system( "clear" );

When you generate two numbers in the DoSubtraction() function, you will have to make sure that the answer is not negative. The way to do that is with an additional variable and swap the two numbers:

```
int nr1;
int nr2;
int temp;

if ( nr1 < nr2 )
{
temp = nr1;
nr1 = nr2;
nr2 = temp;
}
}

```

## Functions

Write one function to -- REQUIRED:

1. DisplayInstructions(): Display the instructions -- needs no arguments and returns no values.
2. DoAddition(): Do the addition problems -- needs arguments and returns values.
3. DoSubtraction(): Do the subtraction problems -- needs arguments and returns values.
4. DoMultiplication(): Do the multiplication problems -- needs arguments and returns values.
5. DoDivision(): Do the division problems DoDivision() -- needs arguments and returns values.

## Sample output

```                                        CMSC104 Tutor

1.  Display Instructions

3.  Subtraction Problems

4.  Multiplication Problems

5.  Division Problems

6.  Exit Program

```

```Inside DisplayInstructions
Press  to continue
```

```1:  4 + 7 = 3
1:  4 + 7 = 99
1:  4 + 7 = 11
That's CORRECT!!!!!!!   0.00% correct
2:  1 + 4 = 5
That's CORRECT!!!!!!!   0.50% correct
3:  9 + 5 = 14
That's CORRECT!!!!!!!   0.67% correct
4:  10 + 4 = 14
That's CORRECT!!!!!!!   0.75% correct
5:  10 + 6 = 16
That's CORRECT!!!!!!!   0.80% correct
Press  to continue
```

```6:  6 - 1 = 5
That's CORRECT!!!!!!!   0.83% correct
7:  3 - 1 = 5
7:  3 - 1 = 1
7:  3 - 1 = 2
That's CORRECT!!!!!!!   0.71% correct
8:  2 - 1 = 1
That's CORRECT!!!!!!!   0.75% correct
9:  10 - 1 = 9
That's CORRECT!!!!!!!   0.78% correct
10:  7 - 2 = 5
That's CORRECT!!!!!!!   0.80% correct
Press  to continue
```

```11:  35 / 5 = 7
That's CORRECT!!!!!!!   0.82% correct
12:  14 / 7 = 4
12:  14 / 7 = 1
12:  14 / 7 = 2
That's CORRECT!!!!!!!   0.75% correct
13:  12 / 3 = 4
That's CORRECT!!!!!!!   0.77% correct
14:  28 / 4 = 7
That's CORRECT!!!!!!!   0.79% correct
15:  63 / 7 = 9
That's CORRECT!!!!!!!   0.80% correct
Press  to continue
```

```16:  8 * 4 = 14
16:  8 * 4 = 99
16:  8 * 4 = 32
That's CORRECT!!!!!!!   0.75% correct
17:  5 * 9 = 45
That's CORRECT!!!!!!!   0.76% correct
18:  9 * 3 = 27
That's CORRECT!!!!!!!   0.78% correct
19:  7 * 9 = 63
That's CORRECT!!!!!!!   0.79% correct
20:  3 * 8 = 24
That's CORRECT!!!!!!!   0.80% correct
Press  to continue
```

Notice that after the first set, you should have a line that summaries the results thus far:
```Number of problems done so far:  20       0.80%

CMSC104 Tutor

1.  Display Instructions