outline of the main method for evaluating expressions This outline does not consider bad expressions. To check for that, you need to make sure that every time you need to look at the stack (examining the top, or pop) the stack is not empty. You also need to check that if you are looking for a '(' in the stack, (i.e. while oprtr.top != '(' ) the oprtr stack is not empty. Otherwsie there is no matching '(' and the expression is bad. evaluate pops two operands from the operand stack, pops and operator from the operator stack, applys the operator to the two operands and pushes the result back onto the operand stack. You need to make sure that the operand and operator stacks have what you are looking for. Otherwise the expression is bad. while not end of input line do { tk=next input if oprand (tk) opnd.push(tk); else if operator (tk) { if oprtr.isempty() oprtr.push(tk); else if tk == '(' oprtr.push(tk); else if priority (tk) > priority(oprtr.top) oprtr.push(tk); else if priority(tk) < priority (oprt.top) evaluate () else if associativity(tk) == L evaluate() else oprtr.push(tk); else if tk == ')' while oprtr.top != '(' evaluate () } else error("wrong symbol); } // end while while (oprt != NULL) evaluate() once the oprator stack is empty, the operand stack should have only one value and that is the result of evaluating the expression.