public static double evaluate(String expression) { Stack stack = new Stack(); StringTokenizer tokenizer; tokenizer = new StringTokenizer (expression); while (tokenizer.hasMoreTokens()) { char word = tokenizer.nextToken().charAt(0); double first = Double.parseDouble(stack.pop().toString()); double second = Double.parseDouble(stack.pop().toString()); switch (word) { case '+': stack.push(first + second); break; case '-': stack.push(first - second); break; case '*': stack.push(first * second); break; case '/': stack.push(first / second); break; default: stack.push(word); break; } } // finish this method return stack.pop().toString();// change the 0.0 to the answer off of the stack }// end evaluate