Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hendrizzzz/computer-programming-2-midterm-project-1-calculator-app
Java application made with Java Swing that serves as a calculator with a primary focus on handling fractions. It provides functionality for performing arithmetic on both regular fractions and/or mixed fractions and reducing fractions to their simplest forms.
https://github.com/hendrizzzz/computer-programming-2-midterm-project-1-calculator-app
inheritance oop swing-gui
Last synced: 23 days ago
JSON representation
Java application made with Java Swing that serves as a calculator with a primary focus on handling fractions. It provides functionality for performing arithmetic on both regular fractions and/or mixed fractions and reducing fractions to their simplest forms.
- Host: GitHub
- URL: https://github.com/hendrizzzz/computer-programming-2-midterm-project-1-calculator-app
- Owner: Hendrizzzz
- Created: 2024-04-22T10:06:52.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-22T10:23:52.000Z (10 months ago)
- Last Synced: 2024-11-13T23:14:30.433Z (3 months ago)
- Topics: inheritance, oop, swing-gui
- Language: Java
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fraction Calculator
## Overview
The Fraction Calculator application provides functionality for performing arithmetic operations on fractions and mixed fractions. It includes both a console-based version, FractionTester, and a graphical user interface (GUI) version, FractionCalculatorGUI.
## Console-Based Fraction Tester
### Class Structure
The `FractionTester` class consists of methods and functionalities to handle user input, perform arithmetic operations, and display results.
#### Main Method
- `main(String[] args)`: Entry point of the program. Creates a `FractionTester` object and invokes the `run()` method.#### Run Method
- `run()`: Main logic of the program. Continuously prompts the user for input and performs operations based on user choices.#### Operation Methods
- `operate(int operation, int typeOfFractions)`: Performs arithmetic operations on fractions.
- `performFractionOperation(T first, U second, int operation)`: Performs specified operations on two fractions.
- `reduce(int typeOfFraction)`: Reduces fractions to their simplest form.#### Input Methods
- `readTypeOfFraction()`: Reads the type of fraction to reduce from user input.
- `readTypeOfFractions()`: Reads types of fractions involved in an operation from user input.
- `readOperation()`: Reads the operation to perform from user input.
- `readMenuOption(int max)`: Reads a menu option from user input.
- `readInteger(String promptMessage)`: Reads an integer value from user input.#### Display Methods
- `displayResult(Fraction firstFraction, Fraction secondFraction, Fraction resultingFraction, String operation)`: Displays arithmetic operation results.
- `displayResult(MixedFraction fraction, MixedFraction result)`: Displays reduced fraction results.### Classes
- **Fraction**: Represents a fraction with numerator and denominator.
- **MixedFraction**: Extends Fraction to handle mixed fractions.
- **FractionCalculatorGUI**: GUI version for fraction calculations.## Graphical User Interface (GUI)
### FractionCalculatorGUI
Provides a GUI for performing fraction calculations, including reducing fractions and performing arithmetic operations.
#### Constructor
- `FractionCalculatorGUI()`: Constructs the GUI interface for fraction calculations.#### Dependencies
- Java Swing for GUI components.
- Java AWT for layout management and event handling.![Fraction Calculator GUI](https://github.com/Hendrizzzz/CS-122-LAB-/assets/139997209/bd4f0fb8-d6a6-4a65-8c0b-546b109437fc)
## Dependencies
- Java Development Kit (JDK) installed on the system.
## How to Run
1. **Clone the Repository:**
```bash
git clone https://github.com/Hendrizzzz/Computer-Programming-2-Midterm-Project-1-CALCULATOR-APP
```2. **Navigate to the Project Directory:**
```bash
cd Computer-Programming-2-Midterm-Project-1-CALCULATOR-APP
```3. **Compile and Run the Program:**
```bash
javac edu/slu/prog2/*.java
java edu.slu.prog2.FractionTester
```## Note
- `FractionTester` operates in the console and does not have a GUI.
- The GUI version, `FractionCalculatorGUI`, provides a more interactive user experience.