Question: Java, modify this code, package expeval; public class Token { private final static String[] validOperators = {+,-,*,/,%}; private String body; private final static char OPENPAREN
Java, modify this code,

package expeval; public class Token { private final static String[] validOperators = {"+","-","*","/","%"}; private String body; private final static char OPENPAREN = '('; private final static char CLOSEDPAREN = ')'; public Token(String tok) { body = tok; } public String getBody() { return body; } public boolean isOperator() { for (int i = 0; i expression; public Expression(String exp) { expression = new ArrayList(); StringTokenizer strTok = new StringTokenizer(exp," "); while (strTok.hasMoreElements()) { Token tok = new Token((String) strTok.nextElement()); expression.add(tok); } } public Expression() { expression = new ArrayList(); } public int size() { return expression.size(); } public void add(Token newElement) { expression.add(newElement); } public String toString() { String ret = ""; for (int i = 0; i getExpression() { return expression; } } package expeval; import stack.*; import java.util.*; public class PostfixEvaluator { private Expression postfixExpression; private int valueOfExpression; public PostfixEvaluator(Expression postfix) { postfixExpression = postfix; } public int eval() { //Starts with an empty operand stack IStack operandStack = new ArrayListStack(); //Temp variable Token nextToken; ArrayList postfix = postfixExpression.getExpression(); //Main Loop: Parse the postfix expression for (int k = 0; k operatorStack = new ArrayListStack(); Token nextToken = null; Token topOfStack = null; ArrayList expr = infixExpression.getExpression(); for (int k = 0; k stackPrecedence) operatorStack.push(nextToken); else { while ((tokenPrecedence Your assignment: Write a GUI-based program that evaluates a C-style arithmetic expression and displays its value. Study the Code given to you in each of the classes and figure out what needs to handle the C-style expressions. Modify the Token class to handle all the additional operators such as , etc. and PostixEvaluatox classe to handle all the operators specified above. Modify the ExpTRASOntwluatorTeate, to handle ALL the test expressions (33 expressions) gven in the above Eramples table. * Write an EpressinIclass to produce a display as shown below. The user enters the expression in to the top-right box and the system will output the value in the box below r Infix Expression 3+5 (5-7) 10) of Expression Calculate Exit Turn in: .Modified Code: Only the classes that you modified. Your code must be wl .Execution Window showing the execution of the Tester. The tester should test The GUI showing the evaluation of this expressionsin (DO NOT COPY documented using ivadoc-style ll the examples given in the above table. PASTE Type them into the textfield. 102 lad 3 + 2 * 10 )-10-5)/3 25 + ( 10 > 5 ) * 3 ) % 6 Your assignment: Write a GUI-based program that evaluates a C-style arithmetic expression and displays its value. Study the Code given to you in each of the classes and figure out what needs to handle the C-style expressions. Modify the Token class to handle all the additional operators such as , etc. and PostixEvaluatox classe to handle all the operators specified above. Modify the ExpTRASOntwluatorTeate, to handle ALL the test expressions (33 expressions) gven in the above Eramples table. * Write an EpressinIclass to produce a display as shown below. The user enters the expression in to the top-right box and the system will output the value in the box below r Infix Expression 3+5 (5-7) 10) of Expression Calculate Exit Turn in: .Modified Code: Only the classes that you modified. Your code must be wl .Execution Window showing the execution of the Tester. The tester should test The GUI showing the evaluation of this expressionsin (DO NOT COPY documented using ivadoc-style ll the examples given in the above table. PASTE Type them into the textfield. 102 lad 3 + 2 * 10 )-10-5)/3 25 + ( 10 > 5 ) * 3 ) % 6 Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
