http://www.developer.com/tech/article.php/952051/User-Code-W3Eval.htm
W3Eval is a
Java applet that evaluates mathematical expressions step by step.
It uses a different approach than that of a conventional calculator, which is more
natural to the way people calculate. When you calculate on a conventional
calculator, each time you enter a new number you lose sight of the
previous one. And if you make a mistake in the middle of a long expression,
you have to start all over. In W3Eval, you can see all of what you are
calculating, and expressions can easily be edited. The W3Eval screen consists of three parts:
Tree is located on the left part of the screen and contains all operators, variables,
and functions. It is used both as help and expression builder. When you double-click
or press <Enter> on any of the terminal nodes, a template is pasted into
the expressions area. The expressions area is the upper text area of the screen. It can contain multiple
expressions separated with an empty line.
Features:
This code sample shows the definitions of the classes used for representing functions, operators, and variables:
Requirements:
Java users are encouraged to submit samples of useful code for publication
in the pages of Gamelan. Send your files and comments to editor@developer.com for
consideration. Thank you.
User Code: W3Eval
January 9, 2002
{
public String function;
public int number_of_arguments;
public Function( String function, int number_of_arguments )
{
this.function=function;
this.number_of_arguments=number_of_arguments;
}
public String toString()
{
return function;
}
}
public class Operator
{
public String operator;
public byte priority;
public Operator( String operator, byte priority )
{
this.operator=operator;
this.priority=priority;
}
public String toString()
{
return operator;
}
}
public class Variable
{
public String variable;
public double value;
public Variable( String variable, double value )
{
this.variable=variable;
this.value=value;
}
public String toString()
{
return variable;
}
}
About the Author
Nikola Stepan is a software engineer at ABIT Ltd., in Croatia, where he works on banking software design and development.