Requirement
CMPSC 121
Spring 2017
Lab 6- Functions
Write a program that can be used as a math tutor for a young student. Use the rand function to produce two positive integers between 1 and 20.
The program should display a menu allowing the user to select an addition, subtraction, or multiplication problem. The final selection on the menu should let the user quit the program.
After the user has finished the math problem, the program should check the student’s answer and display whether it is correct and display the menu again. This process is repeated until
the user chooses to quit the program. If the user selects an item not on the menu, program should display an error message and ask the user to enter a valid number. Be sure to divide the
program into functions that perform. each major task.
Sample run:
Math Tutor Menu
——————————
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Quit this program
——————————
Enter your choice (1-4): 2
10 - 7 = 3
Congratulations! That’s right.
Math Tutor Menu
——————————
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Quit this program
——————————
Enter your choice (1-4): 8
The valid choices are 1, 2, 3, and 4. Please choose: 3
7 * 12 = 74
Sorry, the correct answer is 84.
Math Tutor Menu
——————————
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Quit this program
——————————
Enter your choice (1-4): 4
Thank you for using Math Tutor.
Upload your source file (.cpp) via Angel.