Part 1

Write a program where the user inputs their monthly budget. The loop should then ask the user to input each of their monthly expenses. These expenses should be kept in a running total. The final output should display if the user is over or under their budget for the month, and by how much.

import java.util.HashMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Budget {

    static ArrayList<String> months = new ArrayList<>(Arrays.asList(
        "january",
        "february",
        "march",
        "april",
        "may",
        "june",
        "july",
        "august",
        "september",
        "october",
        "november",
        "december"
    ));

    private HashMap<String, Integer> monthlyExpenses;
    private HashMap<String, Integer> monthlyBudget;

    public Budget() {
        this.monthlyExpenses = new HashMap<>();
        this.monthlyBudget = new HashMap<>();
    }

    public void setMonthlyExpenses() {

        Scanner scanner = new Scanner(System.in);

        for (String month : months) {
        
            System.out.println("Enter the monthly expenses for " + month + ": ");
            String input = scanner.nextLine();
            this.monthlyExpenses.put(month, Integer.parseInt(input));

        }

        
    }
    
    public void setMonthlyBudget() {
     
        Scanner scanner = new Scanner(System.in);

        for (String month : months) {
        
            System.out.println("Enter the monthly budget for " + month + ": ");
            String input = scanner.nextLine();
            this.monthlyBudget.put(month, Integer.parseInt(input));

        }

    }

    public int findDifference() {
        int sum = 0;

        for (String month : months) {
            sum += monthlyBudget.get(month);
            sum -= monthlyExpenses.get(month);
        }

        return sum;
    }

    public void findDifferenceToString() {
        System.out.println("Your difference is " + this.findDifference());
    }

    public static void main(String[] args) {
        Budget budget = new Budget();
        budget.setMonthlyBudget();
        budget.setMonthlyExpenses();
        budget.findDifferenceToString();
    }
}

Budget.main(null);
Enter the monthly budget for january: 
Enter the monthly budget for february: 
Enter the monthly budget for march: 
Enter the monthly budget for april: 
Enter the monthly budget for may: 
Enter the monthly budget for june: 
Enter the monthly budget for july: 
Enter the monthly budget for august: 
Enter the monthly budget for september: 
Enter the monthly budget for october: 
Enter the monthly budget for november: 
Enter the monthly budget for december: 
Enter the monthly expenses for january: 
Enter the monthly expenses for february: 
Enter the monthly expenses for march: 
Enter the monthly expenses for april: 
Enter the monthly expenses for may: 
Enter the monthly expenses for june: 
Enter the monthly expenses for july: 
Enter the monthly expenses for august: 
Enter the monthly expenses for september: 
Enter the monthly expenses for october: 
Enter the monthly expenses for november: 
Enter the monthly expenses for december: 
Your difference is -617

Part 2

google test score