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

So I am trying to create a java method to convert arithmetic expressions from in

ID: 3908510 • Letter: S

Question

So I am trying to create a java method to convert arithmetic expressions from infix notation to postfix notation.

This is the code I have currently, however the method is messing up somewhere and I can't spot why.

here are the outputs I am getting: the lines with the parenthesis' still in them are the infix input, the line below is the output after running the above method.

private void infixToPostfix) t /**COMPLETE StringStack stack new StringStack ) TokenList listnew TokenList) String token; for (int i? ; iinfixTokens . size ( ) ; 1++) { token = ínfíxTokens.get(i); // setting the current token value into 'token' variable if (isoperand (toke//if token is not an operator & not a bracket else if (token--"("){ else if (isoperator (token))f list.append (token) //append operand to list stack.push (token) while (!stack.isEmpty() && stack . peek()'="(" && getPrecedence (token)

Explanation / Answer

after fetching one operator it shoul fetch corresponding operand from stack

instead of using two saperate data structure use stack it will work properly