Question
Write 3 individual c ++ programs that use a stack to work with infix / postfix equations and equation verification. Verify equations based on balanced
Write 3 individual c ++ programs that use a stack to work with infix / postfix equations and equation verification.
- Verify equations based on balanced parentheses, brackets, and curly braces. (50)
- Examples of good equations:
- (a + b)/c
- (2-1)+(2+3)
- {[(a + b) * a]/b} + 1
- a + (b /c)
- Examples of bad equations:
- (a + b/c
- ()((())
- {if you eat a lot}/(you will belch)
- Examples of good equations:
- Evaluate post fix equations.(100)
- Example:
- 1 2 + 3 * => results in 6
- 2 3 3 + * => results in 12
- Example:
- Infix to PostFix (100)
- Example:
- (a + b)*c => ab+c*
- a + b * c => abc*+
- Example:
4. Take all of the above c++ programs and combine them into one separate program.
Requirements:
1. Must be in c++;
2. No built in types. must make own functions and classes.
3. Make it as simple as possible.
*Write a snippet of code into the main program that combines all 3 programs to read in the test values from a text file.
Test Material:
1. parentheses tests
x = ((1 + 2)*3
x = (1 + 2))*3
y = (z * j)/(b * 8)^2
2. postfix equation solving
7 3 + 9 *
5 2 + 1 9 * *
8 9 * 3 5 + -
2 + 8 4 /
3. infix to postfix conversion
(8 + 4) * 9
(6 + 3) * (2 * 8)
(9 * 8) (5 + 3)
3 + (9 / 3)
4. Parentheses check, infix to postfix conversion, postfix evaluation
(8 + 4) * 9
(6 + 3) * (2 * 8)
(9 * 8) (5 + 3)
3 + (9 / 3)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started