Question: Write a simple java program that meets the following requirements: 1.Your program should read two integer values from the user and store them in variables

Write a simple java program that meets the following requirements:

1.Your program should read two integer values from the user and store them in variables namely num1 and num2 respectively.

2. Your program should then prompt the user to enter a number between 1 and 3 inclusive and store the user input into a variable named userChoice.

Note: Your prompt message in this step (step 2) should look like: "Please enter a number between 1 and 3 inclusive, where 1: Addition, 2: Subtraction, 3: Division."

3. Using if-else, check for one of the possible cases: if the value stored in userChoice is 1, then compute and display the result of num1+num2; if the value stored in userChoice is 2, then compute and display the result of num1-num2; if the value stored in userChoice is 3, then compute and display the result of num1/num2; Otherwise, display the message "Invalid Input."

4.Repeat above step (step 3) using switch statement.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!