Write a simple calculator which supports add subtract multiply and divide. Prompt the user for two numbers and an operation. Use number 1-4 for menu options. If divide is selected and the second number is zero, output an error message. If an invalid menu option is selected, output an error message. If all is well, perform the operation and output the result to one decimal. Please write in Java that results like test case examples. Thanks

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter5: The Repetition Structure
Section: Chapter Questions
Problem 15E
icon
Related questions
Question
Write a simple calculator which supports add subtract multiply and divide. Prompt the user for two numbers and an operation. Use number 1-4 for menu options. If divide is selected and the second number is zero, output an error message. If an invalid menu option is selected, output an error message. If all is well, perform the operation and output the result to one decimal. Please write in Java that results like test case examples. Thanks
Test Case 4
Enter first number \n
Enter your se
9 ENTER
Enter second number \n
3 ENTER
Enter a menu option\n
[1] Add \n
[2] Subtract \n
[3] Multiply \n
[4] Divide \n
4 ENTER
9.0 / 3.0 = 3.0 \n
Test Case 5
Enter first number \n
10 ENTER
Enter second number \n
ENTER
Enter a menu option \n
[1] Add \n
[2] Subtract \n
[3] Multiply \n
[4] Divide \n
4 ENTER
If division is selected the second number cannot be zero \n
Transcribed Image Text:Test Case 4 Enter first number \n Enter your se 9 ENTER Enter second number \n 3 ENTER Enter a menu option\n [1] Add \n [2] Subtract \n [3] Multiply \n [4] Divide \n 4 ENTER 9.0 / 3.0 = 3.0 \n Test Case 5 Enter first number \n 10 ENTER Enter second number \n ENTER Enter a menu option \n [1] Add \n [2] Subtract \n [3] Multiply \n [4] Divide \n 4 ENTER If division is selected the second number cannot be zero \n
Test Case 7
Enter first number \n
10.5 ENTER
Enter second number \n
3.1 ENTER
Enter a menu option \n
[1] Add \n
[2] Subtract \n
[3] Multiply \n
[4] Divide \n|
4 ENTER
10.5/ 3.1 = 3.4 \n
Test Case 8
Enter first number \n
0 ENTER
Enter second number\n
25 ENTER
Enter a menu option \n
[1] Add \n
[2] Subtract \n
[3] Multiply \n
[4] Divide \n
5 ENTER
Invalid menu option
Transcribed Image Text:Test Case 7 Enter first number \n 10.5 ENTER Enter second number \n 3.1 ENTER Enter a menu option \n [1] Add \n [2] Subtract \n [3] Multiply \n [4] Divide \n| 4 ENTER 10.5/ 3.1 = 3.4 \n Test Case 8 Enter first number \n 0 ENTER Enter second number\n 25 ENTER Enter a menu option \n [1] Add \n [2] Subtract \n [3] Multiply \n [4] Divide \n 5 ENTER Invalid menu option
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT