Search⌘ K
AI Features

Build with Prompts

Explore how to bring a Budget Tracker app to life by coding essential methods like addIncome and addExpense in Java. Learn to structure your program with class fields and methods, use AI to generate additional functions step-by-step, and test your code. This lesson helps you build a functional, interactive app while preparing for error handling and code refinement.

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. ...

// 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<>();
...