Question: Write a program to simulate a menu driven calculator that performs basic arithmetic operations (add, subtract, multiply and divide). The calculator accepts two numbers and
Write a program to simulate a menu driven calculator that performs basic arithmetic operations (add, subtract, multiply and divide). The calculator accepts two numbers and an operator from the user in a given format:
For example:
Input: 6.3 / 3
Output: 2.1
Create a Calculator class that has a method to choose the right mathematical operation based on the entered operator using switch case. It should then call a corresponding method to perform the operation.
In the main method of the testing class create an object of Calculator and accept user's input using the Scanner object. The user should be offered a choice to continue with the next operation.
Step by Step Solution
There are 3 Steps involved in it
Heres a Java program that implements a menudriven calculator import javautilScanner public class Cal... View full answer
Get step-by-step solutions from verified subject matter experts
