**********Evaluator.java**************** package evaluator; import java.util.*; import operand.Operand; import operator.Operator; public class Evaluator { private Stack<Operand> operandStack; private Stack<Operator> operatorStack; private StringTokenizer tokenizer; private static final String DELIMITERS = "+-*^/() "; public Evaluator() { operandStack = new Stack<Operand>(); operatorStack = new Stack<Operator>(); } public int eval(String expression) { int result = 0; String token; Operator hashOpr = Operator.operators.get("#"); oprStack.push(hashOpr); String delimiters = "+-*/#!"; // The 3rd argument is true to indicate that the delimiters should be used // as tokens, too. But, we'll need to remember to filter out spaces. this.tokenizer = new StringTokenizer(expression, DELIMITERS, true); while (this.tokenizer.hasMoreTokens()) { // filter out spaces if (!(token = this.tokenizer.nextToken()).equals(" ")) { // check if token is an operand if (Operand.check(token)) { operandStack.push(new Operand(token)); } else { if (!Operator.check(token)) { System.out.println("*****invalid token******"); System.exit(1); } // TODO Operator is abstract - this line will need to be fixed: // ( The Operator class should contain an instance of a HashMap, // and values will be instances of the Operators. See Operator class // skeleton for an example. ) Operator newOperator = null; // new Operator( token ); while (operatorStack.peek().priority() >= newOperator.priority()) { // note that when we eval the expression 1 - 2 we will // push the 1 then the 2 and then do the subtraction operation // This means that the first number to be popped is the // second operand, not the first operand - see the following code Operator oldOpr = operatorStack.pop(); Operand op2 = operandStack.pop(); Operand op1 = operandStack.pop(); operandStack.push(oldOpr.execute(op1, op2)); } operatorStack.push(newOperator); } } } // Control gets here when we've picked up all of the tokens; you must add // code to complete the evaluation - consider how the code given here // will evaluate the expression 1+2*3 // When we have no more tokens to scan, the operand stack will contain 1 2 // and the operator stack will have + * with 2 and * on the top; // In order to complete the evaluation we must empty the stacks (except // the init operator on the operator stack); that is, we should keep // evaluating the operator stack until empty // Suggestion: create a method that takes an operator as argument and // then executes the while loop; also, move the stacks out of the main // method return 0; } /** * Class to help test your Evaluator: * javac EvaluatorTester * java EvaluatorTester "1+2" "3*5" */ public static void main(String[] args) { Evaluator evaluator = new Evaluator(); for (String arg : args) { System.out.format("%s = %d\n", arg, evaluator.eval(arg)); } } } ************************************Operand.Java************************************************** package operand; public class Operand { public .