Question: In this project, is asking to write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator: The
In this project, is asking to write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator:
The calculator has one accumulator, which holds the result of all prior calculations. The calculator is set to 0.0 when the calculator is turned on (i.e., instantiated).
On the console, the user then enters an operator (+, -, *, or /) and a number. Your console will then apply the operator and operand to the number in the accumulator, and store the result back in the accumulator
The user can also enter R to reset the accumulator to 0, or the letter P to turn the calculators power off
The calculator will need to trap the following exception conditions:
If the user enters something other than +, -, *, /, R, or P for the operator, an UnknownOperatorException exception should be thrown.
If the user enters something other than a valid number for the operand, a NumberFormatException exception should be thrown. (You can ignore this exception if the user enters R or P for the operator.)
If the user tries to divide by zero, an DivideByZeroException exception should be thrown.
The NumberFormatException is already provided in Java. You will write your own UnknownOperatorException and DivideByZeroException classes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
