Question: Write a program that can be used as a math helper for Addition, subtraction, and multiplication problems. The program should generate two random integer numbers.
Write a program that can be used as a math helper for Addition, subtraction, and multiplication problems. The program should generate two random integer numbers. One number must be between 15 and 30 inclusive, and the other one must be between 40 and 70 inclusive; to be added or subtracted. The program then prompts the user to choose between addition or subtraction or multiplication problem.
Math
-----------
Enter + for Addition Problem
Enter - for Subtraction Problem
Enter * for Multiplication
Then based on the users choice use a switch statement to do the following:
-
If the user enters + then an addition problem is presented.
-
If the user enters - then a subtraction problem is presented.
-
If the user enters * then a subtraction problem is presented.
-
If anything, else besides +, - or * is entered for the operator, the program must say so and then ends
Once a valid choice is selected, the program displays that problem and waits for the student to enter the answer.
If the answer is correct, a message of congratulation is displayed, and the program ends.
If the answer is incorrect, a Sorry message is displayed along with the correct answer before ending the program.
Your output must look like the one given. Note that the numbers could be different.
Hints:
-
Review generating random numbers in Chapter 3 of your textbook.
Example output of a correct guess:
Math
----------
Enter + for Addition Problem
Enter - for Subtraction Problem
Enter * for Multiplication Problem
+
Here is your problem
25
+ 20
---
45
Congratulations!!! That is correct
Goodbye!
Example output of an incorrect guess:
Math
-----------
Enter + for Addition Problem
Enter - for Subtraction Problem
Enter * for Multiplication Problem
*
Here is your problem
18
* 20
---
567
Sorry, the correct answer is: 360
Goodbye!
Example output if the user enters any other operate beside +, - or *:
Math
-----------
Enter + for Addition Problem
Enter - for Subtraction Problem
Enter * for Multiplication Problem
/
Illegal operator
Goodby!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
