Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Math Tutor/help please

+6 votes
asked Oct 17, 2018 by Christina1 (310 points)

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:

  1. Declare your variables, including the correct answer
  2. Display the menu and prompt the user for their choice
  3. Make sure it is a valid choice
  4. For each possible choice:
    1. Figure out the two operands appropriately
    2. Determine and store the correct answer
    3. Display the problem (formatted nicely!)
  5. Assuming they didn't hit 5 to exit, prompt for the answer
  6. Provide feedback on the user's answer
  7. 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.

1 Answer

0 votes
answered Feb 2, 2021 by Jeff The Chicken (2,920 points)
Try learning about code and writing the code yourself, and If you get stuck you can use the Q&A.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...