This project is a GUI-based scientific calculator developed in Java using the Swing framework. It is designed to demonstrate object-oriented programming concepts, such as modularization, event-driven programming, and file handling.
- Basic Operations: Addition, subtraction, multiplication, and division.
- Scientific Functions: Trigonometric operations (SIN, COS, TAN) and usage of π.
- Display Label: Shows real-time input and results.
- History Menu:
- View History: Displays past calculations in a scrollable window.
- Delete History: Clears the saved calculation history.
- Persistent Storage: Saves and retrieves calculation history from a text file.
- Ensure you have Java JDK 8 or later installed.
- Add the
exp4j
library to your project for expression evaluation. - Compile and run the program in your preferred IDE (e.g., IntelliJ IDEA, Eclipse).
- The GUI calculator window will appear, allowing you to perform operations.
The project is divided into the following files:
- Calculator.java: Main class to initialize the GUI and layout.
- MenuBar.java: Handles the creation of the menu bar and its actions.
- DisplayLabel.java: Manages the display label for inputs and outputs.
- Buttons.java: Generates buttons dynamically and assigns actions.
- History.java: Displays the calculation history in a new window.
- FileHandling.java: Handles saving, reading, and deleting calculation history.
- Object-Oriented Design: Separation of concerns into multiple classes.
- Event Handling: Button click actions and menu item listeners.
- File I/O: Reading and writing history to a text file.
- Layout Management: Using
GridBagLayout
for flexible GUI design.
This project was developed as part of the OOP Assignment 4 under the guidance of Mr Ali Sher Kashif at COMSATS University, Sahiwal for for the Bachelor of Computer Science program.
- Muhammad Safiullah Khan
- Registration Number: FA23-BCS-273
- Institution: COMSATS University, Sahiwal
This project is released under the MIT License. Feel free to use and modify it as needed.