I'm needing to evaluate string infix equations and transform them to postfix equations.
I'm following the info here: http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm

1.) I'm confused by this line: "compare the precedence of the character with the element on top of the stack"
It's asking me to compare the precedence of an operand to an operator. I'm not sure what it means by that. I can understand the idea of precedence between two operators, but not between an operator and an operand.

2). I'm needing to identify whether or not each character from a string is an operator or not. (+, -, *, etc.) In addition to those, I'm also needing to deal with parentheses in the equations.
I used Character.isLetter(character) and Character.isDigit(character) to determine if each character of the string is a letter or number (operands), so I'm wondering if there is a shortcut like that I can use instead of having to test each character of the string against each individual possible operator...

Tips are appreciated! :)

update to previous post:

I have the first question figured out and also most of the second.
I'm not sure of how to directly compare the precedence of two operators without doing a bunch of if statements. Is there a quicker way?
However, I'm still not sure how I should handle the parentheses in the equations.

Examples of equations:
1) (a + b)*c ==> ab+c*
2) a + b * c ==> abc*+


ps - Why do the Edit This Post buttons disappear after a while? :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.