This is a simple calculator application built in Java. The application uses Swing for the GUI and follows a modular approach for easy maintenance and scalability.
(C) Solomon Blount
This was a school project where we had to do the following:
- Implement the basic functionality of the calcualtor (layout design, input text field, result text field, numbers 0 to 9, buttons.
- Data buttons (which I call modifier buttons) such as Power Buttons (x^2, x^3), Mod, Log Buttons, etc
- Trigonometry Buttons including sin, cos, tan, asin, acos, atan, sinh, cosh, tanh
- A clear and exit button.
Absoultely do NOT use this to cheat on a calculator project similar to this. Doing so may result in an academic integrity violation. You may, however, use this as motivation and strategize a unique way of making your calculator and/or use PARTS of this code.
There is no license for this, meaning this is open domain with no legal restrictions but should you choose to use this as an example PLEASE include my name, Solomon Blount as the copyright holder.
The project is structured as follows:
-
Main.java
: This is the main entry point of the application. It sets up the GUI and handles the main logic of the calculator. -
CoreButton.java
: This file defines the core functionality of a button in the calculator such asC
,=
, andEXIT
. -
MathNode.java
: This file defines theMathNode
class, which is used to represent mathematical operations in the calculator. -
ModifierButton.java
: This file defines theModifierButton
class, which is used to represent buttons that modify the state of the calculator such asMod
,Sin
,Cos
,1/n
and more. -
NumericButton.java
: This file defines theNumericButton
class, which is used to represent numeric buttons in the calculator (0-9). -
OperationFunc.java
: This file defines theOperationFunc
class, which is used to represent mathematical operations in the calculator. -
Operator.java
: This file defines theOperator
class, which is used to represent mathematical operators in the calculator. -
OperatorButton.java
: This file defines theOperatorButton
class, which is used to represent operator buttons in the calculator such as+
,-
,/
,*
, and more. -
StateButton.java
: This file defines theStateButton
class, which is used to represent buttons that change the state of the calculator. The only state buttons are the.
and the+/-
which may change the visual representation of the working operation.
You may find where all of these buttons are dynamically defined here.
To run the application, compile all the .java
files and then run the Main
class.
cd CalculatorApp\src
javac *.java
java Main
Please note that you need to have Java installed on your machine to run this application.