Search⌘ K
AI Features

Build with Prompts

Explore building a Budget Tracker in Java by implementing key methods like addIncome and addExpense. Learn how to structure your code with class fields, methods, and an interactive CLI loop. Use AI prompts to generate and test remaining functions, enhancing your coding skills step-by-step in a practical project.

In the previous lesson, you:

  • Chatted with a simulated client and gathered needs.

  • Converted notes into functional requirements.

  • Created a clean skeleton of eight method stubs.

Now, we’ll bring it to life. We’ll start with two core methods, and then use AI to scaffold the rest. You’ll also get quick tests and a full reference solution.

We’ll keep a tiny in-memory data model:

In Java, instead of global variables, we usually use class fields. At the top of your class, you’ll declare fields that store your app’s data.

We’ll keep a tiny in-memory data model:

// Globals (top of your file)
private static double income = 0.0;
// A list of expense entries, each stored as a Map<String, Object>
private static List<Map<String, Object>> expenses = new ArrayList<>();

Here are the conventions that we’ll use here:

  • Positive amounts only.

  • Built-ins only, pure Java (with no external libraries, no file I/O, and no advanced classes beyond simple POJOs). ...

Build the basics