public static double process_postfix(String postfix, HashMap<String,
            Integer> map) {
        Stack<Double> stack = new Stack<Double>();
        String opers = "+-*/";
        String[] tokens = postfix.split(" ");
        for (String token : tokens) {
            if (opers.indexOf(token.charAt(0)) == -1) {
                double term = 0.;
                try {
                    term = Double.parseDouble(token);
                } catch (NumberFormatException ex) {
                    term = map.get(token);
                }
                stack.push(term);
                // If token is an operator
            } else {
                double b = stack.pop(), a = stack.pop();
                if (token.charAt(0) == '+') {
                    a = a + b;
                } else if (token.charAt(0) == '-') {
                    a = a - b;
                } else if (token.charAt(0) == '*') {
                    a = a * b;
                } else if (token.charAt(0) == '/') {
                    a = a / b;
                }
                stack.push(a);
            }
        }
        return stack.pop();
    }