Console Applications
Personal Expense Tracker
Build a console application that records income and expenses, organizes transactions by category, calculates the current balance, and displays a financial summary.
What you will build
Build a robust CLI expense tracker from scratch that manages finances and persists data to a local file.
Learning objectives
- After completing the project, the learner should understand:
- Master file I/O operations by reading from and writing structured data to text/CSV files
- Design and implement custom data models (classes/structs) to represent real-world entities
- Manage application state and dynamic collections (arrays, lists, vectors) in memory
- Build a robust, interactive command-line interface with a continuous menu loop
- Implement data aggregation algorithms (calculating totals and filtering records by category/date)
- Handle edge cases and parse user input safely to prevent application crashes
- Apply Object-Oriented Programming (OOP) principles like encapsulation and separation of concerns
Prerequisites
- Basic understanding of variables, loops, and conditional statements
- Familiarity with creating functions/methods and passing arguments
- Basic knowledge of classes/objects (if using an Object-Oriented language)
- Understanding of standard console input and output (reading from keyboard, printing to screen)
Core requirements
Project milestones
- Create the menu
Create the main menu and repeatedly ask the user to select an option, rejecting invalid inputs and exiting safely.
- Design a transaction
Define the information stored for each transaction (ID, Type, Amount, Category, Description, Date) using a Class, Record, Structure, or Object.
- Add income and expenses
Create the workflow for entering and validating transaction details (Amount > 0, Category not blank, Valid date format).
- Store multiple transactions
Use an appropriate collection (ArrayList, vector, List, Array) to store the transaction objects in memory.
- Calculate the summary
Loop through all transactions and calculate total income, total expenses, and current balance using decimal-safe money types.
- Group expenses by category
Accumulate expenses separately for each category using a Map or Dictionary.
- Add search and deletion
Allow the user to filter by type/category, find by ID, and securely delete a transaction from the list.
- Add file persistence
Load existing transactions on startup and save them after a change. Ensure the app doesn't crash if the file is missing.
Sample interaction
========================================
PERSONAL EXPENSE TRACKER
========================================
1. Add income
2. Add expense
3. View all transactions
4. View financial summary
5. View expenses by category
6. Search transactions
7. Delete a transaction
8. Save transactions
9. Exit
Choose an option:Testing checklist
- Add a new expense and verify it immediately appears when viewing the list
- Enter an invalid menu option (e.g., '9') and ensure the program doesn't crash
- Enter text (like "abc") when the program asks for an expense amount and verify the error is handled gracefully
- Close the program entirely, restart it, and verify that previously saved expenses are loaded correctly
- View the summary and verify that the math for the total sum is 100% correct
- Try deleting an expense ID that doesn't exist and ensure the program handles it properly
Choose an implementation
Save your progress
Sign in to save completed milestones and continue this project later.
Sign in or registerDownload Reference Solution
This project's reference solution is completely free. Sign in to get instant access.
Sign in to download free