Write a program to model a simple calculator


Question (Loops, Math, method, string, selection)
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 accumulator value (initial value of 0.0). You need a method doNextOp that performs the required operation. doNextOp has three input parameters (the operator, the left operand, and the right operand), and return the result of the computation. The valid operands are:
+ add
¬- subtract
*multiply
/ divide
^ power (raise left operand to power of right operand)
q quit
your calculator should display the accumulator value after each operand. A sample run follows:
A simple calculator
~~~~~~~~~~~~~~~
+ 5.5
Result so far is 5.5
* 2
Result so far is 11.0
^2
Result so far is 121.0
/ 10.0
Result so far is 12.1
- 11.5
Result so far is 0.5999999999999996
*2
Result so far is 1.199999999999999
/ 5
Result so far is 0.23999999999999985
+ 10
Result so far is 10.24
q 0
Final result is 10.24 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write a program to model a simple calculator
Reference No:- TGS0131285

Expected delivery within 24 Hours