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