A complete Java console application that minimizes the number of cash-settlement transactions among people.
- Pure Java 17+: No external libraries required.
- Object-Oriented Design: Dedicated
Personmodel. - Interactive Menu:
- Run with custom input
- Test sample
- Exit
- Flexible Input Formats:
Num txns NN- Followed by
Nlines ofPayer Payee Amount
- Efficient Algorithm:
- Computes net balances using
HashMap<String, Integer>. - Builds debtor/creditor lists and minimizes transactions with a greedy two-pointer approach.
- Computes net balances using
- Robust Handling:
- Zero balances
- Exact matches
- Multiple cycles
- CSV Export: Optional export of minimized payments.
- Standalone Tests: No JUnit dependency.
src/CashFlowMinimizer.java→ Main app, algorithm, menu, CSV persistence.src/Person.java→ OOP model for settlement participants.src/Test.java→ Standalone test runner for correctness.docs/console-demo.svg→ Demo screenshot image.
- Java 17 or higher
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd cashflow-minimizer-java - Compile the project:
javac src/*.java - Run the application:
java src/CashFlowMinimizer
- Compile the test file:
javac src/Test.java
- Run the tests:
java src/Test
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add your message here" - Push to your branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
⭐ Star this repo if you find it helpful! ⭐