
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Write a program that simulates a postfix (a.k.a. “reverse polish”) calculator. In this calculator, you enter a number, press “push”, enter another number and press “push”, then press the button of the operation, such as addition. For example: 10.1
•Your calculator must support addition, subtraction, multiplication, division, sine, cosine, and square root. •To implement this program, you must read from the keyboard and display to the console. You must not build a GUI for this program. Therefore, you need a simple, command line user interface. When a user enters a number (and presses the “enter” key), you will push the number on a stack. When a user enters a function (either one of the operation keys, “+”, “-“, “*”, or “/”) or a function name (“sin”, “cos”, or “sqrt”), you will pop the operands off the stack, execute the operation, then push the result on top of the stack. You should display the top of stack after each operation.