Expense Tracker
Track spending by category, with totals, category totals and the biggest expense.
Project 5Intermediate
๐งฉ Problem statement
Each expense is written as “CATEGORY:AMOUNT:DESCRIPTION”. Show the total spent, the total per category (as a map), and the single highest expense as “DESCRIPTION (AMOUNT)”.
๐ Requirements
- Add expense
- Category
- Total
- Category totals
- Highest expense
- Date filter (extension)
๐ฅ Inputs
- EXPENSES: a list of text entries
๐ค Outputs
- Total
- Category totals map
- Highest expense
๐ Rules
- Amounts are positive
๐ง Constraints
- At least one expense
๐งญ Suggested approach
- Split each entry
- Accumulate the total
- Accumulate per category in a map
- Track the maximum
๐ง Required concepts
- Maps
- Strings
- Accumulators
- Min/max
โ๏ธ Pseudocode editor ยท dry-run tool ยท test cases
Design your solution here. Use Run to dry-run it step by step and Run tests to check it. Hints unlock one at a time โ try on your own first!
๐งช Edge cases to test
- A single expense
- Two expenses with the same highest amount
- Many categories
๐ Complexity analysis
O(n) time; O(c) memory for c categories.
๐ Solution walkthrough (open after youโve tried!)
One pass does three jobs at once: a running total, a per-category total using the map-counting pattern (but adding amounts), and a best-so-far for the highest expense. NUMBER turns the amount text into a number so the maths works.
๐ Challenge extensions
- Add dates ("2026-09-01") and total per month
- Show categories sorted from highest to lowest
- Warn when a category exceeds a budget