Question: *CANCEL Write a C++ program to convert infix expressions into their postfix expressions using a stack. Your program will also evaluate the values of expressions
*CANCEL
Write a C++ program to convert infix expressions into their postfix expressions using a stack. Your program will also evaluate the values of expressions using their postfix expressions. You should use a stack when converting expressions into their postfix expressions and you should also use a stack when evaluating their values.
In infix expressions, operands are a single lowercase letters and operators are +, -, * and /. Precedence values of * and / are same, and their precedence values are higher than precedence values of + and -. Possible infix expressions and their postfix expressions are as follows:
Infix Expression Postfix Expression
a+b*c abc*+
a*b*c+d*e*f+g*h ab*c*de*f*+gh*+
(a+b)*c ab+c*
a*b/c*d ab*c/d*
a-b+c-d ab-c+d-
Your program should contain the following five source files:
LLNode.h should contain a linked list node class
LinkedList.h should contain a linked list class based on LLNode class
Stack.h should contain a stack class based on LinkedList class
Expression.h should contain an expression class
hw01main.cpp should contain your main function which tests all four classes and their functions.
Your class definitions and your function implementations should be in four .h files. The structure of these four files are given below, and you are NOT allowed to change the headers of the functions in these four classes. You should only implement constructors and functions that are given in those classes. You may add a new function into Expression.h (such as precedence function).
*CANCEL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
