Question: please do it using Java. thank you! 5) (15 pts) Assume that we ssume that we are given a number and we carry out a
5) (15 pts) Assume that we ssume that we are given a number and we carry out a sequence of 1 operations (multiplication, division, subtraction, summation) mathematical operations (multiplication, divi on the number (5 pts) Define a class Operation which has fields for the first operand. operation type (*,/,-, +) and second operand. This class should also implement a method Do(), which returns the result of the operation, and a method Undo(), which reverts the oper- ation. b. (5 pts) Let number = 10 initially and assume we carry out the following operations in the given order: multiply number by 7, divide number by 2, subtract 30 from number, multiply number by 3, add 6 to number. For each of these operations create an instance of Operation and store in a Stack(Operation). Calculate the new value of number with your Do() method. Show the current status of the stack after each operation. C. (5 pts) Revert the operations carried out using the stack metho your Undo() method. Show the current status of the stack after each operation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
