import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print("\nšŸ’° Budget Management System šŸ’°"); print("1. Add Income"); print("2. Add Expense"); print("3. View Summary"); print("4. Exit"); stdout.write("Choose an option: "); String? choice = stdin.readLineSync(); if (choice == "4") { print("Exiting... Have a great day!"); break; } switch (choice) { case "1": stdout.write("Enter income description: "); String desc = stdin.readLineSync()!; stdout.write("Enter amount: "); double? amount = double.tryParse(stdin.readLineSync()!); if (amount != null && amount >= 0) { incomeList.add({desc: amount}); print("āœ… Income added successfully."); } else { print("āŒ Invalid amount."); } break; case "2": stdout.write("Enter expense description: "); String desc = stdin.readLineSync()!; stdout.write("Enter amount: "); double? amount = double.tryParse(stdin.readLineSync()!); if (amount != null && amount >= 0) { expenseList.add({desc: amount}); print("āœ… Expense added successfully."); } else { print("āŒ Invalid amount."); } break; case "3": 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("\nšŸ“Š Summary:"); print("Total Income: \$${totalIncome}"); print("Total Expenses: \$${totalExpenses}"); print(net >= 0 ? "Your net profit is \$${net}" : "Your net loss is \$${net.abs()}"); // Optional tax calculation (15%) if (net > 0) { double tax = net * 0.15; print("Tax to be paid: \$${tax.toStringAsFixed(2)}"); } break; default: print("āŒ Invalid choice, try again."); } } }