Question: Assignment 4 Postfix Calculator The stack based calculator is constructed using the postfix notation. In this assignment, we are to implement the postfix calculator using

Assignment 4 Postfix Calculator

The stack based calculator is constructed using the postfix notation. In this assignment, we are to implement the postfix calculator using the Stack and Queue from the Combo class that we build previously.

We are to create one queue to hold all input tokens and one stack for hold the operands. The calculation shall follow the depicted description above.

This program shall not check the validity of the postfix expression. It is assumed that the test pattern is valid. Use this online infix to postfix converter http://www.mathblog.dk/tools/infix-postfix-converter/ to generate a valid postfix expression from infix expression for your choice.

Your program shall implement and show:

the user input

the calculation of following 4 operators: + - * /

tracing of all the content of the Operand Stack and Postfix Queue between changes.

Sample Test Output

For this exercise we are to use a line prompt for user to enter a postfix expression.

Assignment 4 Postfix Calculator The stack based calculator is constructed using the 

Running /home/ubuntu/workspace/comsc210/m04/comboCalculator.cpp Enter a postfix expression, q to quit: 12345+-+* Operand Stack Postfix Queue 2, 1 3, 2, 1 4, 3, 2, 1 5, 4, 3, 2, 1 3, 2, 1 9, 3, 2, 1 = 4+5 2, 1 -6, 2, 1 = 3-9 -4 1*-4 = Enter a postfix expression, q to quit: Running /home/ubuntu/workspace/comsc210/m04/comboCalculator.cpp Enter a postfix expression, q to quit: 12345+-+* Operand Stack Postfix Queue 2, 1 3, 2, 1 4, 3, 2, 1 5, 4, 3, 2, 1 3, 2, 1 9, 3, 2, 1 = 4+5 2, 1 -6, 2, 1 = 3-9 -4 1*-4 = Enter a postfix expression, q to quit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!