public static void computeOperator(Stack<Float> stack, String operator) {
        //Be careful with the order you pop things off here.
        //Choose an order and stick with it.
        float b = stack.pop();
        float a = stack.pop();
        float result;

        //If we had more operators, we wouldn't use cascading if/else statements
        if (operator.equals("+")) {
            result = a + b;
        } else if (operator.equals("-")) {
            result = a - b;
        } else if (operator.equals("*")) {
            result = a * b;
        } else if (operator.equals("/")) {
            result = a / b;
        } else if (operator.equals("^")) {
            result = (float) Math.pow((double) a, (double) b);
        } else {
            //We've encountered an unknown operator.
            //We'll ignore it and move on, pushing the operands back onto the stack.
            //Be careful you push the numbers back in the right order.
            stack.push(a);
            stack.push(b);

            //Return here so we don't push a zero onto the stack.
            return;
        }
        stack.push(result);
    }