public static String convert_to_postfix(String expr) {
        Stack<Character> op_stack = new Stack<Character>();
        StringBuilder out = new StringBuilder();
        String opers = "+-*/()";
        char top_sym = '+';
        boolean empty;
        String[] tokens = expr.split(" ");
        for (String token : tokens) {
            if (opers.indexOf(token.charAt(0)) == -1) {
                out.append(token);
                out.append(' ');
            } else {
                while (!(empty = op_stack.isEmpty()) && precedence(top_sym =
                        op_stack.pop(), token.charAt(0))) {
                    out.append(top_sym);
                    out.append(' ');
                }
                if (!empty) {
                    op_stack.push(top_sym);
                }
                if (empty || token.charAt(0) != ')') {
                    op_stack.push(token.charAt(0));
                } else {
                    top_sym = op_stack.pop();
                }
            }
        }
        while (!op_stack.isEmpty()) {
            out.append(op_stack.pop());
            out.append(' ');
        }
        return out.toString();
    }