import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print("Welcome to the Budget Management Application!"); while (true) { print("\n1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit"); stdout.write("Enter your choice: "); String? choice = stdin.readLineSync(); if (choice == "4") { print("Exiting the application. Goodbye!"); break; } switch (choice) { case "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 ?? "Income": amount}); print("Income added!"); } else { print("Invalid amount!"); } break; case "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 ?? "Expense": amount}); print("Expense added!"); } else { print("Invalid amount!"); } break; case "3": double totalIncome = 0; double totalExpense = 0; for (var entry in incomeList) totalIncome += entry.values.first; for (var entry in expenseList) totalExpense += entry.values.first; double netProfit = totalIncome - totalExpense; double tax = netProfit > 0 ? netProfit * 0.15 : 0; print("\nSummary:"); print("Total income: \$${totalIncome.toStringAsFixed(2)}"); print("Total expenses: \$${totalExpense.toStringAsFixed(2)}"); if (netProfit >= 0) { print("Net profit: \$${netProfit.toStringAsFixed(2)}"); print("Tax to be paid: \$${tax.toStringAsFixed(2)}"); } else { print("Net loss: \$${netProfit.toStringAsFixed(2)}"); } break; default: print("Invalid choice!"); } } }