Final Project

By the end of this capstone you'll have built a complete console Expense Tracker from scratch — classes, a List<T> store, a menu loop, LINQ reports, and a path to saving data — pulling together everything the whole C# course has taught you.

Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.

Part of the free C# course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

This project is a victory lap. Each feature below maps straight back to a lesson you've already finished — nothing here is new, it's all combined .

Up to now you've been learning the individual instruments — the class drums, the List<T> bass, the LINQ keyboards. A finished program is the band playing together . The tune is the user's journey: open the app, see a menu, add an expense, ask for a report, save and quit. Each instrument you learned has a part to play, and your job in this capstone is to conduct them so they make one coherent piece of music — a real, usable tool.

Real software is never written all at once — you start with a skeleton that runs, then grow it one feature at a time, testing after each. You'll do exactly that here, in three stages:

Stage 1 — The Starter Skeleton

Here is the foundation: an Expense class (the domain model ), a List<Expense> to hold many of them, and a menu loop that reacts to choices. To keep the output predictable in this runner, the loop walks a fixed script instead of reading the keyboard — when you build the real app you'll swap that one line for Console.ReadLine() . Read every comment, run it, and notice the listing feature already works; the other features are yours to add.

Stage 2 — Your Turn: Add an Expense

First feature to build: adding an expense to the store. An AddExpense method needs to do two things — build a new Expense object, then append it to the list with .Add(...) . Fill in the two ___ blanks using the hints, then run it; the program will add three expenses and report the count.

Stage 2 — Your Turn: Build a LINQ Report

A list of expenses is only useful once you can summarise it. This is LINQ's moment: Sum gives a grand total, and GroupBy followed by Sum gives a per-category breakdown. Fill in the two ___ blanks (both are the same method!), then run it to see your spending ranked highest-first.

It's worth seeing the whole data flow in one glance. The class is the shape of one record; the list is the store ; the methods are the verbs that act on the store; LINQ is how you ask questions of it.

Every console app you ever write follows this same skeleton: a model, a store, verbs that change the store, and queries that read it. Learn it here and you can build almost any small tool.

No blanks now — just a feature checklist in comments. Turn the starter into a finished, persistent app by adding these one at a time, running after each. Every technique you need comes from a lesson you've already completed, so reach back to those when you're stuck.

Q: Why does the starter use a fixed script instead of Console.ReadLine() ?

So the example produces the same output every time in this in-page runner, which lets you self-check against the expected block. In your own real app on your machine, swap the scripted loop for while (true) reading Console.ReadLine() — that's the first feature in the Extend It step.

You already started: run the Stage 1 starter, then do the two guided steps. After that, add Extend It features one at a time and run after each. A program is just many small, tested steps stacked up.

Q: Could I build something other than an expense tracker?

Absolutely — the skeleton (model → list → menu → LINQ → save) fits a to-do list, a contacts book, a mini inventory, or a habit tracker. Swap the Expense class for your own type and keep the same shape.

Q: Why decimal for the amount and not double ?

double can't represent values like 0.1 exactly, so money totals drift by tiny fractions. decimal is built for exact base-10 maths, which is what you want for currency. This came up back in the Variables lesson.

Q: How do I make the data survive after I close the app?

Serialise the list to JSON and write it to a file on exit, then read and deserialise it on startup — Feature 4 in the Extend It step. That's the difference between a toy and a tool.

You reached the end of the C# course — and you didn't just read about it, you built with it.

Look back at how far you've come. Every concept below is now a tool you can pick up and use, and in this capstone you wired them together into a working program:

You can now design a type, store many of them, drive a program with a loop, query data with LINQ, and save it to disk — that's the core of real software. Keep this expense tracker, finish the Extend It features, push it to GitHub, and make it your first portfolio piece. You're ready to build your own projects. 🚀

From variables and loops to OOP, LINQ, exceptions, and files — you've covered the full journey and finished by building something real.

What's next: finish the Extend It challenge, then start a project of your own. Every skill you've learned is ready to use.

Practice quiz

In the expense tracker, what is the role of the Expense class?

  • It stores many expenses
  • It drives the menu loop
  • It is the domain model describing a single expense (Category, Amount, Date)
  • It saves data to disk

Answer: It is the domain model describing a single expense (Category, Amount, Date). The Expense class is the domain model — one type bundling the data (Category, Amount, Date) for a single expense.

Which type holds many Expense objects and grows as you add more?

  • List<Expense>

Answer: List<Expense>. A List<Expense> is the data store; it grows automatically as you Add expenses at runtime.

Why use decimal rather than double for the Amount?

  • decimal is faster
  • double cannot store negatives
  • decimal uses less memory
  • decimal is built for exact base-10 maths, so money totals don't drift

Answer: decimal is built for exact base-10 maths, so money totals don't drift. double can't represent values like 0.1 exactly, so money drifts by tiny fractions. decimal does exact base-10 arithmetic — correct for currency.

Which method appends a new Expense to the list?

  • expenses.Insert()
  • expenses.Add(item)
  • expenses.Append()
  • expenses.Push()

Answer: expenses.Add(item). List<T>.Add(item) appends the new Expense to the end of the list so it's stored.

Which LINQ method gives the grand total of every expense's Amount?

  • Sum(e => e.Amount)
  • Count(e => e.Amount)
  • GroupBy(e => e.Amount)
  • Max(e => e.Amount)

Answer: Sum(e => e.Amount). expenses.Sum(e => e.Amount) totals the Amount across every expense in one call.

To produce a per-category breakdown, you combine which two LINQ operations?

  • Where then Select
  • OrderBy then First
  • GroupBy then Sum
  • Distinct then Count

Answer: GroupBy then Sum. GroupBy(e => e.Category) buckets by category, then Sum on each group totals that category's spending.

Which using directive must be present to call Sum and GroupBy?

  • using System.IO;
  • using System.Linq;
  • using System.Text.Json;
  • using System.Collections.Generic;

Answer: using System.Linq;. Sum, Where, and GroupBy are LINQ extension methods in System.Linq — forgetting it causes CS1061 ('does not contain a definition for Sum').

Why use decimal.TryParse instead of decimal.Parse on user input?

  • TryParse is faster
  • Parse cannot read decimals
  • TryParse rounds the value
  • TryParse returns false on bad input instead of throwing, so a typo doesn't crash the app

Answer: TryParse returns false on bad input instead of throwing, so a typo doesn't crash the app. decimal.Parse("abc") throws; TryParse returns false for invalid input so you can show a message instead of crashing.

How do you make the expense data survive after the app closes?

  • Keep it in a static List forever
  • Serialise the list to JSON and write it to a file, then load it on startup
  • Print it to the console
  • Use a larger List capacity

Answer: Serialise the list to JSON and write it to a file, then load it on startup. Serialise the List to JSON, write it to a file on exit, and deserialise it on startup — that's the difference between a toy and a real tool.

Why is the List<Expense> declared as a static field rather than a local variable inside a method?

  • Static fields are faster
  • Because local lists can't hold objects
  • So every method (AddExpense, ListExpenses, reports) can see and share the same store
  • To force garbage collection

Answer: So every method (AddExpense, ListExpenses, reports) can see and share the same store. A local list declared in one method isn't visible in another (CS0103). A static field on the class lets every method share the one store.