import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print("\n=== Budget App ==="); 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 amount: "); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({desc ?? 'Income': amount}); print("Added income: $desc - $amount SR"); } else { print("Invalid amount!"); } } else if (choice == '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 ?? 'Expense': amount}); print("Added expense: $desc - $amount SR"); } else { print("Invalid amount!"); } } else if (choice == '3') { double totalIncome = incomeList.fold(0, (sum, e) => sum + e.values.first); double totalExpense = expenseList.fold(0, (sum, e) => sum + e.values.first); double net = totalIncome - totalExpense; print("\n--- Summary ---"); print("Total Income: $totalIncome SR"); print("Total Expenses: $totalExpense SR"); if (net > 0) { double tax = net * 0.15; print("Net Profit: $net SR"); print("Tax to Pay: $tax SR"); } else if (net < 0) { print("Net Loss: ${net.abs()} SR"); } else { print("No profit or loss."); } } else if (choice == '4') { print("Exiting..."); break; } else { print("Invalid choice!"); } } }