very basic question, anyone who has any programing experience should be able to complete this in about 15 mins r probably less!!
## Deliverables
**Modify the PostFixEvaluator program to use a ListStack and then evaluate the expression:**
** 3 4 * 2 5 + - 4 * 2 /**
** Explain in words the behaviour of the program.**
Shown below is the code that i was provided with in order to start the question
//********************************************************************
// [login to view URL] Authors: Lewis/Chase
//
// Represents an evaluator of postfix expressions. Assumes the
// operands are constants.
//********************************************************************import [login to view URL];
import [login to view URL];public class PostfixEvaluator
{
private final char ADD = '+', SUBTRACT = '-';
private final char MULTIPLY = '*', DIVIDE = '/'; private ArrayStack stack; //-----------------------------------------------------------------
// Sets up this evalutor by creating a new stack.
//-----------------------------------------------------------------
public PostfixEvaluator()
{
stack = new ArrayStack();
} //-----------------------------------------------------------------
// Evaluates the specified postfix expression.
//-----------------------------------------------------------------
public int evaluate (String expr)
{
int op1, op2, result = 0;
String token;
StringTokenizer tokenizer = new StringTokenizer (expr); while ([login to view URL]())
{
token = [login to view URL](); if (isOperator(token))
{
op2 = ((Integer)[login to view URL]()).intValue();
op1 = ((Integer)[login to view URL]()).intValue();
result = evalSingleOp ([login to view URL](0), op1, op2);
[login to view URL] (new Integer(result));
}
else
[login to view URL] (new Integer([login to view URL](token)));
} return result;
}
// Determines if the specified token is an operator.
private boolean isOperator (String token)
{
return ( [login to view URL]("+") || [login to view URL]("-") ||
[login to view URL]("*") || [login to view URL]("/") );
}
// Evaluates a single expression consisting of the specified
// operator and operands.
private int evalSingleOp (char operation, int op1, int op2)
{
int result = 0; switch (operation)
{
case ADD:
result = op1 + op2;
break;
case SUBTRACT:
result = op1 - op2;
break;
case MULTIPLY:
result = op1 * op2;
break;
case DIVIDE:
result = op1 / op2;
} return result;
}
}
## Platform
not entirely sure but i would think that it would in most versions of windows. the program itself has to run on a program called "J Creator"