For this project, you will read an infix expression, convert it to postfix, evaluate the postfix expression, and print out the answer. You will need to define and implement your own Stack class and a Calculator class. Your Stack class should support standard stack operations, which you can implement with either a linked list or an array. You should use a class template Stack in C++, but an integer Stack class would work as well since a character would be considered a subset of integers. Your Calculator class stores an infix operation and it provides the public operations below. Feel free to add private operations and data. The Calculator class should use a character stack to convert infix to postfix (storing operators) and then uses an integer stack to evaluate the expression (storing operands).
For this project, you will read an infix expression, convert it to postfix, evaluate the postfix expression, and print out the answer. You will need to define and implement your own Stack class and a Calculator class. Your Stack class should support standard stack operations, which you can implement with either a linked list or an array. You should use a class template Stack in C++, but an integer Stack class would work as well since a character would be considered a subset of integers. Your Calculator class stores an infix operation and it provides the public operations below. Feel free to add private operations and data. The Calculator class should use a character stack to convert infix to postfix (storing operators) and then uses an integer stack to evaluate the expression (storing operands).
C++ ( I WILL THUMBS DOWN IF YOU USE HJAVA)
![Public operations in Calculator class:
A constructor that receives a valid expression as string like "5* 2^ 3"
postfix() - returns the postfix expression
eval() - returns the result of the expression
setExpr() - receives the infix expression as string and store it
getExpr() - returns the infix expression as string
Your application (main) should perform the following:
Ask the user to input an infix expression. Examples of an infix expressions might be (you
may assume that expressions are valid and tokens are always separated by one space):
17/(2+3) - 13
5 2^3
2^3^2
10* (2+4) + 8 /2
7*(5+6)
Create and use a Calculator object to perform conversion and evaluation
Obtain and print out the postfix expression (examples above)
17 23+/13 -
523 A*
232 AA
10 24 +*82/+
756+*
Obtain and print out the answer of the evaluation (examples above)
-10
40
512
64
77
Your program must be able to work with int operands and it must recognize binary
operators +, -, *, / , %, and ^. In addition, it must recognize the parenthesis: (). You can
assume that the user will input a valid infix expression. Your program will continue to
process expressions until the user enters 0 as an expression (use a sentinel loop). Run
the following 3 test cases plus 2* 3*4 as the minimum set of test cases.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fcdf05303-e54f-46cb-92e4-6a9a4c6a9dd8%2Fd59d388f-a757-4c6a-8e66-c3f628254107%2Ft8ga5yo_processed.png&w=3840&q=75)
![Sample input/output:
[Your name) Calculator Enter 0 to exit the program
Enter an expression: 17/ ( 2 + 3) - 13<E
Postfix expression: 17 2 3 + / 13
Result: -10
Enter an expression: 5 * 2 ^ 3<E>
Postfix expression: 5 2 3 ^ *
Result: 40
Enter an expression: 2 ^3^ 2<E>
Postfix expression: 2 32 ^^
Result: 512
Enter an expression: 0<E>
Thanks for using my calculator.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fcdf05303-e54f-46cb-92e4-6a9a4c6a9dd8%2Fd59d388f-a757-4c6a-8e66-c3f628254107%2Frl0e0fh_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)