Write a program to model a simple calculator


Write a program to model a simple calculator. Each data line should consist of the next operation to be performed from the list below and the right operand. Assume the left operand is the accumulator value (initial value of 0). You need a function scan_data with two output parameters that returns the operator and right operand scanned from a data line. You need a function do_next_op that performs the required operation. do_next_op has two input parameter (the operator and the operand) and one input/output parameter (the accumulator). The valid operations are:
+ add, - subtract, * multiply, / divide, ^ power (raise left operand to the power of right operand), q quit
Your calculator should display the accumulator value after each operation. A sample run follows:
+ 5.0 results in 5.0
^2 raises 5 to the power of 2 and returns 25
/2.0 divides 25 by 2 and returns 12.5

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a program to model a simple calculator
Reference No:- TGS0130038

Expected delivery within 24 Hours