Question
Language: In C++ Requirements:Must comments and following files .cpp and .h files Directions: Write a stack application program to evaluate post-fix expressions. The user will
Language: In C++
Requirements:Must comments and following files .cpp and .h files
Directions: Write a stack application program to evaluate post-fix expressions.
The user will enter a post-fix expression of the form 34+ which means 3+4 345+* which means 3*(4+5) 722+- which means 7-(2+2) as a string. Operators are +, -, and *. Single digit numbers only. No blanks.
Please note that the expression could be wrong. e.g. 3+ too few operands (i.e. cannot pop operand) 345 incomplete expression (i.e. more than the result at the end)
Your program will display the evaluated result (a number) or an error message describing what is wrong. You may assume that no expression will be longer than 12 characters. Since each element of the string is a character, you will need to convert it to an integer to perform arithmetic operations.
Required Test Cases (MUST TEST IN THIS ORDER): 1. 34+ which means 3+4 2. 345+* which means 3*(4+5) 3. 722+- which means 7-(2+2) 4. 34+56++ which means (3+4)+(5+6) 5. 12+34*45+-+ which means (1+2) + ((3*4) - (4+5)) 6. 1234567891234 expression too long 7. + too few operands 8. 3+ too few operands 9. 3# invalid element 10. 2345+
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