Skip to main content

Practice · 3 of 3

Milestone 3: Stream Reports

CHALLENGE
Difficulty: intermediate+25 XP

Add the report layer in Solution (types from milestones 1–2 are available): - static int totalForCategory(Solution.ExpenseStore store, String category) — sum of that category's cents. - static List<String> categoryTotals(Solution.ExpenseStore store) — one "category:cents" line per category, sorted by category name, categories with zero expenses (never saved) excluded. - static Optional<String> biggestSpend(Solution.ExpenseStore store) — the expense id with the highest cents (ties: lexicographically smallest id); empty store → Optional.empty(). Use streams with groupingBy/reducing or toMap merges — the point is expressing aggregation declaratively.

Back to lesson: Practice: Capstone Milestones