Michael Kwayisi

EasyCalc: A GUI Java Scientific Calculator

Twitter · Facebook
Designed to perform basic and scientific computationsDesigned to perform basic and scientific computations

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.


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.


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.

easycalc-0.0.2.zipEasycalc 0.0.2 executable jar file16.81 KiB
easycalc-0.0.2-src.zipEasycalc 0.0.2 complete source code16.15 KiB

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

Comments (14)

  1. Shahid RahmanShahid Rahman
    Feb 18, 2015 16:17 GMT

    How to develop a scientific calculator which have some function like as cube, subtract, sum, product, division, square, sin, cos, tan, and so on.

  2. TorstenTorsten
    Mar 5, 2018 14:05 GMT

    I called this calculator "R.H.N.C" ;-) ( Rediculous Huge Number Calculator ) , because it is capable to calculate 2 to the power of 10.000.000 where the result has millions of digits as a megabyte of numbers in the clipboard.

  3. JayloThaiJayloThai
    Jan 20, 2016 01:50 GMT

    this..so much GOOD

  4. AnkhmanAnkhman
    May 23, 2018 21:35 GMT

    "I do not recommend its usage for any mathematical operation as it has some flaws left unfixed." Can you elaborate as to where these flaws exist in the source code?

    1. Michael KwayisiMichael Kwayisi
      May 24, 2018 02:32 GMT

      After so many years I'm not sure I can tell what needed fixing. But going through the code and reading some of the comments in there, I could sense a feeling of skepticism toward the code I was writing. E.g., in the “About” dialog box I referred to the project as “Q&D” meaning quick and dirty. With that in mind, it’s unsurprising to find out that the “10ˣ” button is merely cosmetic and completely non-functional. On correctness, the implementation of implicit multiplication (Expression.java, line 343) is buggy as is evident in evaluating an expression such as “2 sin 30 + 5!”. In this case, the fix would be to evaluate implicit multiplications before additive ones, not after. There could be others ;)

  5. ThibaultThibault
    Apr 26, 2018 10:10 GMT

    Hey, how to run the program on bluej ? There is 6 java files, so which one i need to put on blue j ? Every one of them ?

    1. Michael KwayisiMichael Kwayisi
      Apr 26, 2018 14:31 GMT

      Sorry I'm not familiar with that program. But from what I could read online, you probably need all the “.java” files, and then run the “static void main(String[] args)” method in the Program class.

  6. Bonsa TesfaBonsa Tesfa
    Jan 10, 2015 09:35 GMT

    I appreciate you and would like to say may God help you to do more!!!!!!!!

  7. jerryjerry
    May 21, 2016 03:40 GMT

    what is the purpose of the "1st", "u" and "clr" keys on the easycalc

    1. Michael KwayisiMichael Kwayisi
      May 21, 2016 18:33 GMT

      They are statistical functions that allow you to add numbers to a list ("lst", contraction of "list"), find the mean/average of the numbers in your list ("u", the Greek letter mu), the sum of the numbers in the list (the sigma letter), or clear/reset the list ("clr"). The number in the space just above the mu key tells you the current number of items in your list.

  8. Noman MehmoodNoman Mehmood
    Apr 20, 2016 08:28 GMT

    Excellent Work

  9. johnsonjohnson
    Jul 13, 2015 17:24 GMT

    brilliant work

  10. SolestySolesty
    Apr 18, 2014 05:57 GMT

    That's my boss. #Applaudise

NOTE: You are replying to 's comment. [Cancel]