jwo.utils
Class JWExpressionParser

java.lang.Object
  |
  +--jwo.utils.JWExpressionParser

public class JWExpressionParser
extends Object

Allows a mathematical expression to be parsed and evaluated.

Version:
1.8.0, 2nd May, 2000.
Author:
Jo Wood

Constructor Summary
JWExpressionParser(String expression)
          Initialises the expression parser with the given expression.
 
Method Summary
 double evaluate(double x, double y, double z)
          Evaluates the algebraic expression.
static void main(String[] args)
          Parses the given expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JWExpressionParser

public JWExpressionParser(String expression)
Initialises the expression parser with the given expression. Removes whitespace and checks expression is legal.

Parameters:
expression - Expression to evaluate.
Method Detail

main

public static void main(String[] args)
Parses the given expression.

Parameters:
args - Command line arguments.

evaluate

public double evaluate(double x,
                       double y,
                       double z)
Evaluates the algebraic expression.

Parameters:
x - Value for x;
y - Value for y;
z - Value for z;
Returns:
Result of evaluated expression. Returns Double.NaN if expression cannot be evaluated.