Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the algorithm convertToPostfix given in photo below, create a class in jav

ID: 3678352 • Letter: U

Question

Using the algorithm convertToPostfix given in photo below, create a class in javathat will convert each of thefollowing infix expressions to postfix expressions for the test case a.

a.) a * b / (c -d)

s. For si Algorithm convertToPostfix(infix) /Converts an infix expression to an equivalent postfic esxpression e simplicity, all operands in our expression are single-letter variables operatorStack - a new empty stack postfix -a new empty string while Cinfix has characters left to parse) nextCharacter next nonblank character of infix switch (nextCharacter) case variable Append nextCharacter to postfix break case 'A break case .+' : case .-' : case . * , : case .1' : while (loperatorStack.isEmptyO and precedence of nextCharacter precedence of operatorStack.peekO) Append operatorStack. peek() to postfix operatorStack.popO operatorStack.push (nextCharacter) break case operatorStack.push(nextCharacter) break case ')' / / Stack is not empty if infix expression is valid : topoperator operatorStack.popO while (topope rator !" ,(') Append topOperator to postfix topoperator operatorStack.pop break default: break// Ignore unexpected characters while (!operatorStack.isEmptyO) topOperator operatorStack.pop) Append topOperator to postfix return postfix

Explanation / Answer

import java.io.IOException; public class InToPost { private Stack theStack; private String input; private String output = ""; public InToPost(String in) { input = in; int stackSize = input.length(); theStack = new Stack(stackSize); } public String doTrans() { for (int j = 0; j
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote