Question
Use a switch statement after displaying the menu of choices. Input Validation: If the user selects an item that is not on the menu, display
Use a switch statement after displaying the menu of choices.
Input Validation: If the user selects an item that is not on the menu, display an error message and loop again to display the menu.(Assume the user enters a single character, use thedefaultconstructor of the switch statement to check for an input error.)
Addition: Choose 2 random numbers. Top number between2 and 500.Bottom number less than top number and between1 and 99.(HINT: Generate num1 and num2, then use a while loop to check that num2 is less than num1. If it's not, then generate a new num2 and keep looping until you find a num2 that fits both criteria: less than the top number and between 1 and 99.)
Subtraction: Choose 2 random numbers. The top number is between2 and 500.The bottom number is between1 and 500and less than the top.
(HINT: use the same technique as above, a while loop to validate that num2 is less than num1)
Multiplication: Choose 2 random numbers between 1 and 12. (Easy, peasy. No while loop needed here.)
Division: Ensure there is no remainder. Number 1 should be between10 and 999.Number 2 is between1 and 9.(HINT: Use a while loop to validate that there is no remainder. The modulus operator is very useful here.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started