import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print("Welcome to the Budget Management Application!\n"); bool exitProgram = false; while (!exitProgram) { print("Please choose an option:"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit"); stdout.write("Enter your choice: "); String? choice = stdin.readLineSync(); if (choice != null) { if (choice == '1') { addEntry(incomeList, "income"); } else if (choice == '2') { addEntry(expenseList, "expense"); } else if (choice == '3') { displaySummary(incomeList, expenseList); } else if (choice == '4') { exitProgram = true; print("Exiting the application. Goodbye!"); } else { print("Invalid choice! Please select 1-4."); } } } } void addEntry(List> list, String entryType) { stdout.write("Enter $entryType description: "); String? description = stdin.readLineSync(); if (description != null && description.isNotEmpty) { stdout.write("Enter $entryType amount: "); String? amountInput = stdin.readLineSync(); if (amountInput != null) { double? amount = double.tryParse(amountInput); if (amount != null && amount > 0) { list.add({description: amount}); print("$entryType added!"); } else { print("Invalid amount! Please enter a positive number."); } } } else { print("Description cannot be empty!"); } } void displaySummary(List> incomeList, List> expenseList) { double totalIncome = 0; double totalExpense = 0; print("\nIncome Entries:"); if (incomeList.isEmpty) { print("- No income entries"); } else { for (var entry in incomeList) { entry.forEach((description, amount) { print("- $description: \$${amount.toStringAsFixed(2)}"); totalIncome += amount; }); } } print("\nExpense Entries:"); if (expenseList.isEmpty) { print("- No expense entries"); } else { for (var entry in expenseList) { entry.forEach((description, amount) { print("- $description: \$${amount.toStringAsFixed(2)}"); totalExpense += amount; }); } } double netProfit = totalIncome - totalExpense; print("\nSummary:"); print("Total income: \$${totalIncome.toStringAsFixed(2)}"); print("Total expenses: \$${totalExpense.toStringAsFixed(2)}"); if (netProfit >= 0) { print("Net profit: \$${netProfit.toStringAsFixed(2)}"); double tax = netProfit > 0 ? netProfit * 0.15 : 0; if (tax > 0) { print("Tax to be paid (15%): \$${tax.toStringAsFixed(2)}"); } } else { print("Net loss: \$${(-netProfit).toStringAsFixed(2)}"); } }