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("Enter your choice: "); String? choice = stdin.readLineSync(); if (choice == '1') { 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) { incomeList.add({desc: amount}); print("Income added!"); } else { print("Invalid amount!"); } } else if (choice == '2') { 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) { expenseList.add({desc: amount}); print("Expense added!"); } else { print("Invalid amount!"); } } else if (choice == '3') { double totalIncome = incomeList.fold(0, (sum, item) => sum + item.values.first); double totalExpenses = expenseList.fold(0, (sum, item) => sum + item.values.first); double net = totalIncome - totalExpenses; print("\nSummary:"); print("Total income: \$${totalIncome}"); print("Total expenses: \$${totalExpenses}"); if (net >= 0) { print("Net profit: \$${net}"); double tax = net > 0 ? net * 0.15 : 0; if (tax > 0) { print("Tax to be paid: \$${tax}"); } } else { print("Net loss: \$${-net}"); } } else if (choice == '4') { print("Exiting the application. Goodbye!"); break; } else { print("Invalid choice. Try again."); } } }