Question: JAVA - In this assignment you will implement the undo feature for a simple calculator. The undo feature must be implemented using a generic or

JAVA - In this assignment you will implement the undo feature for a simple calculator. The undo feature must be implemented using a generic or template-based Stack data structure. You may utilize language supplied libraries (e.g. java.util.stack) or a stack implementation of your own design. No third-party downloads or software installs are allowed. The undo feature must allow for an unlimited number of undo operations. If the user attempts to perform an undo operation and the stack is empty, then a message must be displayed indicating that there are no commands to undo. The calculator portion of the assignment must function as follows. The calculator must be implemented in a stand-alone class called Calculator. The calculator must support only the following operations: addition (+), subtraction (-), multiplication (*), and division (/). The calculator must support whole and real numbers. The calculator must support the following commands: UNDO, CLEAR, EXIT UNDO: Ignores the prior calculation and restores state as if the calculation never occurred. If there are no prior calculations to ignore, then display the message UNDO IS NOT AVAILABLE and request the user to enter a command or calculation request. CLEAR: Resets the calculator to the initial state, returns the Running Total to 0, and clears the undo stack. EXIT: Terminates the program without producing any results. If a command does not start with one of the preceding three commands, then the input is expected to be a calculation request in the following format: The user will supply input into the calculator in the following format: decimal-number operation decimal-number decimal-number: decimal-integer-literal real-literal real-literal: decimal-digits . decimal-digits decimal-integer-literal: decimal-digits decimal-digits: decimal-digit decimal-digits decimal-digit decimal-digit: one of 0 1 2 3 4 5 6 7 8 9 operation: one of + - * / Any input that does no conform to this input format should be rejected with an error message indicating that the input is invalid. The calculator must maintain a running total of all the operations. The running total is the result of the last operation added the running total. For example, if the calculator is presented with the following input:

10 + 5 Sum: 15;

Running Total : 15

20 5 Difference: 15;

Running Total: 30

2 * 3 Product: 6;

Running Total: 36

UNDO Running Total: 30

CLEAR Running Total: 0

EXIT

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!