Build with Prompts
Explore how to bring a Java budget tracker to life by coding core methods for income and expenses. Understand structuring programs with class fields, reusable methods, and interactive loops. Use AI prompts to scaffold additional functionality and test your code step-by-step, building practical skills in Java programming.
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 ...
// 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 ...