Question: Write a bash script for a calculator that does the following: Prompts for an operand followed by an operator and then the second operand. At
Write a bash script for a calculator that does the following:
Prompts for an operand followed by an operator and then the second operand.
At the "Operand" prompt, the user can enter: Any digit, MR, Clear (C), Off (X) At the "Operator" prompt, the user can enter: +, -, *, /, MS, M+, Clear (C), Off(X) Display the answer. As each subsequent operation will use the previous result, prompt the user for the next operator and operand (don't ask for the first operand again)
Note: C means clear result, keep memory. MS stores result in memory. M+ adds result to memory. MR recalls first or second operand. X exits unix.
sample:
Enter operand: 3 Enter operator: + Enter operand: 4 3 + 4 = 7 Enter operator: - Enter operand: 12 7 - 12 = -5 Enter operator: MS -5 -> M Enter operator: * Enter operand: 3 -5 * 3 = -15 Enter operator: C results cleared Enter operand: MR M -> -5 Enter operator: * Enter operand: MR M -> -5 -5 * -5 = 25 Enter operator: M+ 25 + -5 = 20 -> M Enter operator: / Enter operand: X
Good bye.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
