Modify the previous version of this program again so it displays a menu allowing the user to select an addition, subtraction, multiplication, or division 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 display the menu again. This process is repeated until the user chooses to quit the program. If a user selected an item not on the menu, display an error message and display the menu again.
Note: Start with your code from the previous chapter! For this assignment, you are extending your previous project by allowing for subtraction, multiplication, and division, as well as addition. This can be a bit tricky (hence this is worth two assignments), so be careful. Here is a basic outline of what your program should look like:
- Declare your variables, including the correct answer
- Display the menu and prompt the user for their choice
- Make sure it is a valid choice
- For each possible choice:
- Figure out the two operands appropriately
- Determine and store the correct answer
- Display the problem (formatted nicely!)
- Assuming they didn't hit 5 to exit, prompt for the answer
- Provide feedback on the user's answer
- Repeat the loop as necessary
All generated numbers must be random. For addition and subtraction, the range of numbers must be between 50 and 500, like before. For multiplication, limit the numbers to be in the ranges 1-100 and 1-9. For division, generate the denominator in the range of 1-9. The numerator must be a multiple of the denominator (so there are no remainders for division!), no more than 50 times larger. You might have to think about this!
The output should look like this:
Math Tutor Menu
------------------------------
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
------------------------------
Enter your choice (1-5): 4
66 / 6 = 11
Congratulations! That's right.
Math Tutor Menu
------------------------------
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
------------------------------
Enter your choice (1-5): 5
Thank you for using Math Tutor.