void main() { print("Welcome to the Budget Management Application!"); // محاكاة إدخال المستخدم var userActions = [ {'choice': '1', 'desc': 'Sales', 'amount': 10000.0}, {'choice': '2', 'desc': 'Rent', 'amount': 3000.0}, {'choice': '3'}, {'choice': '4'}, ]; List> incomeList = []; List> expenseList = []; for (var action in userActions) { String choice = (action['choice'] as String?) ?? ''; if (choice == '1') { String desc = (action['desc'] as String?) ?? 'Income'; double amount = (action['amount'] is num) ? (action['amount'] as num).toDouble() : 0.0; incomeList.add({desc: amount}); print("\nEnter your choice: 1"); print("Enter income description: $desc"); print("Enter income amount: $amount"); print("Income added!"); } else if (choice == '2') { String desc = (action['desc'] as String?) ?? 'Expense'; double amount = (action['amount'] is num) ? (action['amount'] as num).toDouble() : 0.0; expenseList.add({desc: amount}); print("\nEnter your choice: 2"); print("Enter expense description: $desc"); print("Enter expense amount: $amount"); print("Expense added!"); } else if (choice == '3') { print("\nEnter your 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("Summary:"); print("Total income: \$${totalIncome.toStringAsFixed(0)}"); print("Total expenses: \$${totalExpenses.toStringAsFixed(0)}"); if (net > 0) { double tax = net * 0.15; print("Net profit: \$${net.toStringAsFixed(0)}"); print("Tax to be paid: \$${tax.toStringAsFixed(0)}"); } else if (net < 0) { print("Net loss: \$${net.abs().toStringAsFixed(0)}"); } else { print("No profit, no loss."); } } else if (choice == '4') { print("\nEnter your choice: 4"); print("Exiting the application. Goodbye!"); break; } } }