Skip to content

GUI-Based Calculator in Java using Swing. This is my OOP Class Assigment 4 in COMSATS Sahiwal.

Notifications You must be signed in to change notification settings

safi-io/calculatorSwingJavaOOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator GUI

OOP Assignment 4

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.


Features

  • 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.

How to Run

  1. Ensure you have Java JDK 8 or later installed.
  2. Add the exp4j library to your project for expression evaluation.
  3. Compile and run the program in your preferred IDE (e.g., IntelliJ IDEA, Eclipse).
  4. The GUI calculator window will appear, allowing you to perform operations.

File Structure

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.

Core Concepts Demonstrated

  • 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.

Screenshots

Calculator Interface

Calculator Interface

History Window

History Window


Acknowledgments

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.


Author

  • Muhammad Safiullah Khan
    • Registration Number: FA23-BCS-273
    • Institution: COMSATS University, Sahiwal

License

This project is released under the MIT License. Feel free to use and modify it as needed.

About

GUI-Based Calculator in Java using Swing. This is my OOP Class Assigment 4 in COMSATS Sahiwal.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages