Skip to main content

Practice ยท 3 of 3

Milestone 3: Stream Reports

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.

Difficulty: intermediate

Back to lesson: Practice: Capstone Milestones