Question: In Java Create a program that will convert an expression written in infix notation to postfix notationThis program will need the use of a stackModify
In Java Create a program that will convert an expression written in infix notation to postfix notationThis program will need the use of a stackModify the stack that you created for Homework 5 and use it with this program.Read the infix expressions from a file (name the file anything you want)Write the postfix expressions to a file (name the file anything you want)The expression will only contain single digit numbers (operands)Operators:+ (add)- (subtract)* (multiply)/ (divide)^ (exponentiation)Infix example: A + B / C * DPostfix example: A B C / D * +
Creating postfix expression
When an operand is encountered, append it to the postfix expressionOperands are never put onto the stackWhen ( is encountered, push it onto the stackWhen an operator is encounteredPop the stack (appending to postfix expression) until an operator of lower precedence is on top of the stack or the stack is empty*, / have a lower precedence than ^+, - have lower precedence than *, /( has lower precedence than +, -Push the operatorWhen ) is encountered, pop the stack (appending each element popped to postfix expression) until ( is encountered in stackPop ( but dont add to postfix expressionWhen end of input is reached, pop the stack (appending to postfix expression) until stack is empty
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
