Algorithm to evaluate a fully-parenthesized expression: First check if parentheses are balanced [throw exception if not] create two stacks - one to hold numbers, and one to hold operator types loop through all the tokens in the expression: identify the token (find out what type it is) if token is a number: push it on the number stack if token is an operator: push its type on the operator stack if token is a left parenthesis: ignore it because already checked balance if token is a right parenthesis (means time to perform a calculation): [throw exception if no operator or less than two numbers on the stacks] pop a number - last one pushed, so it is on right side of calculation pop an operator type - to know what calculation to perform pop a second number - for the left side of the calculation perform the calculation, and push the result on the number stack [end of loop - throw exception if operator stack not empty, or if number stack does not have exactly one number left on it] Done: result is on top of number stack