import 'dart:io'; void main() { // قوائم الدخل والمصروفات List> incomeList = []; List> expenseList = []; print('Welcome to the Budget Management Application!'); while (true) { print('\nPlease choose an option:'); print('1. Add Income'); print('2. Add Expense'); print('3. View Summary'); print('4. Exit'); stdout.write('Enter your choice: '); String? input = stdin.readLineSync(); int? choice = int.tryParse(input ?? ''); if (choice == null) { print('Invalid choice. Please enter a number between 1 and 4.'); continue; } if (choice == 1) { // إضافة دخل stdout.write('Enter income description: '); String description = stdin.readLineSync() ?? ''; stdout.write('Enter income amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount <= 0) { print('Invalid amount. Income must be a positive number.'); } else { incomeList.add({description: amount}); print('Income added successfully.'); } } else if (choice == 2) { // إضافة مصروف stdout.write('Enter expense description: '); String description = stdin.readLineSync() ?? ''; stdout.write('Enter expense amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount <= 0) { print('Invalid amount. Expense must be a positive number.'); } else { expenseList.add({description: amount}); print('Expense added successfully.'); } } else if (choice == 3) { // عرض الملخص double totalIncome = 0; double totalExpenses = 0; for (var income in incomeList) { totalIncome += income.values.first; } for (var expense in expenseList) { totalExpenses += expense.values.first; } double net = totalIncome - totalExpenses; print('\n----- Budget Summary -----'); print('Total Income: \$${totalIncome.toStringAsFixed(2)}'); print('Total Expenses: \$${totalExpenses.toStringAsFixed(2)}'); if (net >= 0) { print('Your net profit is \$${net.toStringAsFixed(2)}'); // حساب الضريبة (اختياري) double tax = net > 0 ? net * 0.15 : 0; print('Tax to be paid (15%): \$${tax.toStringAsFixed(2)}'); } else { print('Your net loss is \$${net.abs().toStringAsFixed(2)}'); } } else if (choice == 4) { print('Exiting the application. Goodbye!'); break; } else { print('Invalid choice. Please enter a number between 1 and 4.'); } } }