View the step-by-step solution to:

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...

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

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question