import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print("Welcome to the Budget Management Application!"); while (true) { print("\nPlease choose an option:"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit"); stdout.write("\nEnter your choice: "); String? choice = stdin.readLineSync(); if (choice == '1') { addIncome(incomeList); } else if (choice == '2') { addExpense(expenseList); } else if (choice == '3') { viewSummary(incomeList, expenseList); } else if (choice == '4') { print("Exiting the application. Goodbye!"); break; } else { print("Invalid choice! Please try again."); } } } void addIncome(List> incomeList) { stdout.write("Enter income description: "); String? desc = stdin.readLineSync(); stdout.write("Enter income amount: "); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount < 0) { print("Invalid amount. Please enter a positive number."); return; } incomeList.add({desc ?? 'Unnamed Income': amount}); print("Income added!"); } void addExpense(List> expenseList) { stdout.write("Enter expense description: "); String? desc = stdin.readLineSync(); stdout.write("Enter expense amount: "); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount < 0) { print("Invalid amount. Please enter a positive number."); return; } expenseList.add({desc ?? 'Unnamed Expense': amount}); print("Expense added!"); } void viewSummary(List> incomeList, List> expenseList) { double totalIncome = 0; double totalExpenses = 0; for (var item in incomeList) { totalIncome += item.values.first; } for (var item in expenseList) { totalExpenses += item.values.first; } double net = totalIncome - totalExpenses; print("\nSummary:"); print("Total income: \$${totalIncome.toStringAsFixed(2)}"); print("Total expenses: \$${totalExpenses.toStringAsFixed(2)}"); if (net > 0) { double tax = net * 0.15; print("Net profit: \$${net.toStringAsFixed(2)}"); print("Tax to be paid: \$${tax.toStringAsFixed(2)}"); } else if (net < 0) { print("Net loss: \$${net.abs().toStringAsFixed(2)}"); } else { print("Break-even: No profit, no loss."); } }