Expression Evaluator in java
It is a concept which deals with parsing , operator precedence, parenthesis handling. Let us implement this in java using Stack concept. As everyone knows, Stack is a data structure with Last in First Out concept. Consider the following statement. 8 + 5 * (4 - 3) Where (4-3) -parenthesis +,*,- deals with Operator precedence. Parsing is done using stacks for expression evaluation. Java Implementation: There are three methods(‘eval()’,’isOperator()’ and ‘applyOp()’). The ‘eval()’ function separates value and operator separately. Based on the expression, operator precedence and parenthesis, it executes the expression. ‘isOperator()’ checks it is a operator or not. ‘applyOp()’ is for operator execution. ‘main()’ deals with creating objects for the class and call the function ‘eval()’ to get the output. Program: import java.util.*; import java.util.Stack; public class ExprEvaluator { publi...