# EasyCalc: A GUI Java scientific calculator

EasyCalc is a Graphical User Interface (GUI) scientific calculator written in Java. It has a multi-line display and can evaluate many scientific expressions containing logarithmic, exponential, and/or trigonometric functions. It sports a nice and clean interface similar to that of the Windows 7 calculator. I wrote this program as part of my project requirements during my study at NIIT. I *do not* recommend its usage for any mathematical operation as it has some flaws left unfixed. It is presented here for academic purposes only. The complete source code and compiled binaries are available for download below.

## Features

Being a scientific calculator, EasyCalc allows you to perform all the basic arithmetic operations, and several other complex mathematical operations. It also support a few basic statistical operations. Things that are missing from the calculator are quick access to common constants like pi, e, etc. However, it comes packed with operational features like arbitrary floating point arithmetic, multiple number systems (binary, octal, decimal and hexadecimal), logarithmic, trigonometric, and exponential functions, etc.

### Standard/Scientific modes

EasyCalc starts in Standard mode which allows you to perform only the basic arithmetic operations (addition, subtraction, multiplication, division, modulus, reciprocal, and square roots), but one can switch to Scientific mode which allows more complex operations. In Scientific mode you can type expressions using functions like sin, cos, tan, log, ln (natural log), int (integral), factorial, cube root, exponentials, statistical operations (sum and average), etc. The calculator honors operator precedence in both Standard and Scientific modes.

### Operator precedence

EasyCalc takes the order of operation into account for all calculations. So expressions like 2 + 3 * 4 will yield 14 rather than 20. According to the math that I know, exponents are at the top of the order of precedence (of course behind parenthesis) so an expression like 4 ^ 3 ^ 2 should be evaluated right-to-left as in 4 ^ (3 ^ 2) yielding 262,144. However most scientific calculators ignore this rule, evaluating left-to-right to yield an incorrect 4,096. EasyCalc obeys the rule here. The order of operator precedence implemented in EasyCalc is {roots, powers, reciprocal, factorial}, {functions (sin, cos, tan, log, nl, etc.)}, {explicit multiplicative operators}, {additive operators}, and {implicit multiplication}.

### Postfix input method

The postfix input method allows you to type expressions just like you would write them on paper. For example, if you want to evaluate the expression sin 30, using Windows Calculator, it would require you to type the operand (30) first, and afterwards hit the sin function. In contrast, EasyCalc is declarative, allowing you to type expressions as is. So, for more complex expressions like 2 sin 30, you would type it as is without going through the imperative process of inputting it as sin(30) * 2. Having said that, expressions like 2 sin 30 + 5! will give a tricky result of 241 instead of the expected 121. This is because implicit multiplications (in this case 2 * sin(30)) are evaluated last in the order of operations.

### Multifarious features

EasyCalc supports calculations in four number systems: binary, octal, decimal and hexadecimal. You can perform any operation in any number system you choose, something that even many commercial calculators don't support. The application starts in decimal mode but you can switch to other number systems by clicking on the appropriate button. Other useful features built into EasyCalc are digit grouping (for all number systems), temporal data storage and retrieval, and copying unto the clipboard. These features are either accessible from the menu bar of the application or directly from the application workarea.

## Building the project

Compiling this project's source code should be hassle-free. I compiled mine with JDK 1.7.0_02 but I'm pretty confident that compiling with any other JDK beyond 1.5 will be successful as well.

### Using make

If you have GNU make (my favorite flavor and the one that I wrote the project's makefile for), then building the project is just a piece of cake because of the already-present makefile in the project. This will free you from all the hassles of locating where the source files are and how they are related. You can make all (or simply make) to compile the source code and create a jar archive as well. Other phony targets in the file are the ubiquitous clean, debug (to generate debugging info) and release (to generate no debugging info).

### Without make

If you do not have make, or your flavor of it can't read the makefile properly, or for some reason you need to compile it manually, just know that all the source code files are in the src directory which is at the root of the project. In the same directory is the manifest file named MANIFEST.MF, which you must include in your Java archive, that is, if you are creating one. Compiling the project is just like any other ordinary Java project. Nonetheless, should you encounter any problems, you may contact me for assistance.

## Download

Package | Description | Size |
---|---|---|

easycalc-0.0.2.zip | Easycalc 0.0.2 executable jar file | 16.81 KB |

easycalc-0.0.2-src.zip | Easycalc 0.0.2 complete source code | 16.15 KB |

The license that comes with this software (both the source code and compiled binaries) allows you to distribute, remix, tweak, and build upon your work, even commercially, as long as you credit the author for the original creation. See the in-package LICENSE.txt for additional information.

NOTE: The fonts used in the already compiled programs are Lucida Sans Unicode, Verdana, and Cambria Math. Since Java applications are cross-platform, folks on operating systems other than Microsoft Windows, where some of the above-mentioned fonts may not be installed, may experience a slight visual displeasure. In this setting, you are encouraged to download the source code and modify the fonts to suit your visual styles preferences.