|
|||||||||
| Home >> All >> org >> gui4j >> core >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.gui4j.core.util
Class MathCalc

java.lang.Objectorg.gui4j.core.util.MathCalc
- public class MathCalc
- extends java.lang.Object
This is the main source code for calculator written in Java 1.1 This program emulates a "real" calculator in that is has a simular user interface arranged in a standard order. It provides an advantage over most of the other calculators because you can viewer both the equation and the results at the same time and allows for editing of the entered equation. Also this calculator adheres to the rules of arithmetic where equation are evaluated in the order brackets, exponents, multiplication, division, addition and subtraction.
| Nested Class Summary | |
private static class |
MathCalc.Functions
This class is a helper class to Calc which evaluates the functions that might appear in the equation. |
| Field Summary | |
(package private) java.lang.String |
display
|
| Constructor Summary | |
MathCalc()
|
|
| Method Summary | |
private static java.lang.String |
brackets(java.lang.String swb)
This method clears all brackets from the expression beginning with the inner most bracket and working outwords and from left to right for non nested brackets. |
private static java.lang.String |
constants(java.lang.String swc)
this method replaces constant variable such as e and pe with there numeric values 2.71818... |
static java.lang.String |
evaluate(java.lang.String s)
This method is the controlling method for the evaluation of the mathematical equations |
private static java.lang.String |
exponent(java.lang.String se)
This method deals with exponents in the string |
private static java.lang.String |
func(java.lang.String sf)
This method evaluates all the functions in the expression filler line to see what happens another filler line a third filler line |
private static java.lang.String |
insertMultiply(java.lang.String ins)
insert the * in all positions of the equation of implicit multiplication |
private static java.lang.String |
mult(java.lang.String s)
This method deals with multiplication and division in a string and |
private static java.lang.String |
replace(java.lang.String sb,
int l,
int r,
double d)
replaces the portion of the equation between r and l with the number represented by d |
private static java.lang.String |
resolve(java.lang.String str)
replace all combinations of signs eg. |
private static java.lang.String |
sum(java.lang.String s)
This method evaluates a string containing only addition and subtraction from left to right |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
display
java.lang.String display
| Constructor Detail |
MathCalc
public MathCalc()
| Method Detail |
brackets
private static java.lang.String brackets(java.lang.String swb)
- This method clears all brackets from the expression beginning with the
inner most bracket and working outwords and from left to right for non
nested brackets.
evaluate
public static java.lang.String evaluate(java.lang.String s)
- This method is the controlling method for the evaluation of the
mathematical equations
constants
private static java.lang.String constants(java.lang.String swc)
- this method replaces constant variable such as e and pe with there
numeric values 2.71818... and 3.141259...
sum
private static java.lang.String sum(java.lang.String s)
- This method evaluates a string containing only addition and
subtraction from left to right
mult
private static java.lang.String mult(java.lang.String s)
- This method deals with multiplication and division in a string and
exponent
private static java.lang.String exponent(java.lang.String se)
- This method deals with exponents in the string
func
private static java.lang.String func(java.lang.String sf)
- This method evaluates all the functions in the expression
filler line to see what happens
another filler line a third filler line
replace
private static java.lang.String replace(java.lang.String sb, int l, int r, double d)
- replaces the portion of the equation between r and l with the
number represented by d
insertMultiply
private static java.lang.String insertMultiply(java.lang.String ins)
- insert the * in all positions of the equation of implicit multiplication
resolve
private static java.lang.String resolve(java.lang.String str)
- replace all combinations of signs eg. +- changed to -
|
|||||||||
| Home >> All >> org >> gui4j >> core >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.gui4j.core.util.MathCalc