Question: 2. [30 marks] (Stack Application Infix to Postfix Conversion) Write a program that uses the Stack class template to convert an infix arithmetic expression into

 2. [30 marks] (Stack Application Infix to Postfix Conversion) Write aprogram that uses the Stack class template to convert an infix arithmetic

2. [30 marks] (Stack Application Infix to Postfix Conversion) Write a program that uses the Stack class template to convert an infix arithmetic expression into a postfix arithmetic expression. In infix form, the operator of an arithmetic statement is in-between every pair of operands. For example: a + b a (b c) (a b) c In postfix form, the operands of an arithmetic statement appear followed by the operator One of the virtues of postfix form is that expressions can be written without the need for parentheses. Here are some examples of arithmetic expressions written in postfix form a b + // Equivalent ta + b a b c+ // Equivalent to a *(b c) ab+*// Equivalent to (a + b) * c Please write a C++program that uses an operator stack to convert an infix arithmetic expression that the user enters into a postfix arithmetic expression. Users input the infix arithmetic expressions which only contains the operands, operators and parenthesis symbols. The character # marks the end of the expression. The operands are represented by single lowercase letters, i.e., a, b, c, d, etc, and the operators are +,-, * and /. Assuming the expressions the users enter are all validated. You may call the following functions in main function. // checks if c is an operand bool is_operand (char c) return true: else return false; // checks if c is an operator,,or / /1 checks if c is an operator,, *, or / bool is_operator (char c) return true: else return false; // return the precedence of an operator int get_operator_precedence (char op) int prec 0; prec =1; else if (op== '*' ll op-'/' ) else return preci Three files should be submitted for this program question. 1) the file Stack.h which contains the definition and implementation of Stack class template, 2) the application file a2q2.cpp containing main ) function, 3) a script file a2q2result containing result. Here are the sample runs: The infix expression: The postfix expression: ab+cdte*- The infix expression: a* (b+c)-e The postfix expression: abct e

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!