Java Scientific Calculator


Home ·
Download ·
Design and operation ·
Modes ·
Accuracy of calculations ·
Numbers and arithmetic ·
Roots, powers and logs ·
Trigonometric functions ·
Factorials and combinations ·
Logical functions ·
Memory ·
Statistical calculations ·
Variable expressions ·
Graphing functions ·
Other features and functions ·
Modifying the code ·
Testing the code ·
Known issues ·
Similar projects ·

Modifying and extending the code

You can freely modify the Java source code unter the terms of the gnu General Public License, included with the source code. Pleas elet me know if you have any interesting variations or extensions.

It is easy to create your own functions. To create a function, decide how many arguments it takes, one or two. If it is one variable, decide whether the argument comes before (like square) or after the function (like square root). Then copy the Java class for a similar function the calculator already has. Adding a function to the calculator is a little harder. Have a look at the class to see how functions are added. Choose a location for your button and add it. The Parser class will automatically recognise your function because it is a descendant of PObject and should immediately be able to use it.

The calculator was originally designed to plug into a web application. So you can easily use it to calculate and return a value for some other application. The CalculatorApplet class stores the result of the most recent calculation and is easily modified to pass this result to another class whenever a new value is found.

Feel free to suggest or contribute improvements. I can’t guarantee to incorporate these, but I’m sure the calculator need some of them. One particular area that needs improvement is the code for formatting numbers. Although the output looks nice, the underlying code is not well-structured and could be improved a lot.

The most useful piece of code is the Parser class. It evaluates general expressions. I have thought about modifying it so that it becomes a general expression evaluator, able to translate unknown terms into variables to create general functions.

There is some documentation for the code, created using doxygen. Almost all of the code has Javadoc comments documnenting each class, variable and method.

Last modified: Sat 10 Nov 2012 10:51 am Logo