Question: Assignment 6 This is for c++ the book website with the question on it is https://fall14cs.files.wordpress.com/2016/03/data-abstraction-and-problem-soving-with-c.pdf Chapter 6, Programming Problem 8. This problem must be

Assignment 6 This is for c++ the book website with the question on it is https://fall14cs.files.wordpress.com/2016/03/data-abstraction-and-problem-soving-with-c.pdf Chapter 6, Programming Problem 8. This problem must be modified as follows: This is programming problem number 8 Repeat Programming Problem 6, but use the following algorithm to evaluate an infix expression infix Exp. The algorithm uses two stacks: One stack opStack contains operators, and the other stack val Stack contains values of operands and intermediate results. Note that the algorithm treats parentheses as operators with the lowest precedence. Here is the code that is given For (each character ch in infixexp) { Switch (ch) { Case ch is an operand that is, a digit valstack.push(ch) Break Case ch is a ( opstack.push(ch) Break Case ch is an operator If (opStack.isEmpty()) opStack.push(ch) else if (precedence(ch) > precedence(opStack.peek())) opStack.push(ch) Else { while (!opStack.isEmpty() and precedence(ch) <= precedence(opStack.peek()) Execute opStack.push(ch) } Break Case ch is a ) while (opStack.peek() is not a '(') Execute opStack.pop() Break } } while (!opStack.isEmpty()) Execute result = valStack.peek() The solution must be able to handle input expressions that contain spaces and valid multi-digit integers. So, something like this (( 15 + 2 * 3 - 4 ) / 17 + ( 22 / 11 * 3)) * 101 must work properly. And The operator stack opStack contains characters, but the operand stack valStack contains integers Your solution should display the postfix expression resulting from the translation from infix before evaluating the expression to produce the numerical result. Your program must repeatedly accept input, translate, and evaluate, until the input contains a single period. (i.e., just a '.')

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!