I\'m working on a project in Java that requires me to convert an infix expression to a postfix expression. I am currently able to convert infix expressions to postfix with t
Try this way:
//opening Parenthesis
if (in_fix.peek().type == 4) {
post_fix.push(in_fix.pop());
}
//closing Parenthesis
if(in_fix.peek().type == 5){
//Till opening parenthesis encountered in stack, append operators to postfix. and pop parenthesis and do not append to post_fix.
while(post_fix.peek().type!=4){
postfixstr.append(post_fix.pop());
}
//finally pop left parenthesis from post_fix stack.
post_fix.pop();
}