UMBC CMSC104 |
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
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.)
For 20% extra credit, you must also show the problem 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() function (stdlib.h), 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.)
Example:
The random number generator has a seed that will determine the sequence of numbers you will get when you use rand( ). The way to get a new sequence is to start with a new seed. If you can make sure the new seed is sufficient different each time you run the program, it will look totally random. 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.
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; } }
Write one function to -- REQUIRED:
CMSC104 Tutor 1. Display Instructions 2. Addition Problems 3. Subtraction Problems 4. Multiplication Problems 5. Division Problems 6. Exit Program Enter your choice:
Inside DisplayInstructions (Your instructions go here.) Pressto continue
1: 4 + 7 = 3 Sorry, that is not right. Your answer is too low. 1: 4 + 7 = 99 Sorry, that is not right. Your answer is too high. 1: 4 + 7 = 11 That's CORRECT!!!!!!! 00% correct 2: 1 + 4 = 5 That's CORRECT!!!!!!! 50% correct 3: 9 + 5 = 14 That's CORRECT!!!!!!! 67% correct 4: 10 + 4 = 14 That's CORRECT!!!!!!! 75% correct 5: 10 + 6 = 16 That's CORRECT!!!!!!! 80% correct Pressto continue
6: 6 - 1 = 5 That's CORRECT!!!!!!! 83% correct 7: 3 - 1 = 5 Sorry, that is not right. Your answer is too high. 7: 3 - 1 = 1 Sorry, that is not right. Your answer is too low. 7: 3 - 1 = 2 That's CORRECT!!!!!!! 71% correct 8: 2 - 1 = 1 That's CORRECT!!!!!!! 75% correct 9: 10 - 1 = 9 That's CORRECT!!!!!!! 78% correct 10: 7 - 2 = 5 That's CORRECT!!!!!!! 80% correct Pressto continue
11: 35 / 5 = 7 That's CORRECT!!!!!!! 82% correct 12: 14 / 7 = 4 Sorry, that is not right. Your answer is too high. 12: 14 / 7 = 1 Sorry, that is not right. Your answer is too low. 12: 14 / 7 = 2 That's CORRECT!!!!!!! 75% correct 13: 12 / 3 = 4 That's CORRECT!!!!!!! 77% correct 14: 28 / 4 = 7 That's CORRECT!!!!!!! 79% correct 15: 63 / 7 = 9 That's CORRECT!!!!!!! 80% correct Pressto continue
16: 8 * 4 = 14 Sorry, that is not right. Your answer is too low. 16: 8 * 4 = 99 Sorry, that is not right. Your answer is too high. 16: 8 * 4 = 32 That's CORRECT!!!!!!! 75% correct 17: 5 * 9 = 45 That's CORRECT!!!!!!! 76% correct 18: 9 * 3 = 27 That's CORRECT!!!!!!! 78% correct 19: 7 * 9 = 63 That's CORRECT!!!!!!! 79% correct 20: 3 * 8 = 24 That's CORRECT!!!!!!! 80% correct Pressto continue
Number of problems done so far: 20 80% correct CMSC104 Tutor 1. Display Instructions 2. Addition Problems 3. Subtraction Problems 4. Multiplication Problems 5. Division Problems 6. Exit Program Enter your choice: