Mathematical expression evaluator in Java