// مشروع: تطبيق إدارة الميزانية (Budget Management App) // يساعد المستخدم على تسجيل الدخل والمصروفات وحساب الأرباح والضرائب // تم إنشاؤه بواسطة: فاطمة محمد import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print('\nاختر خيارك:'); print('1. إضافة دخل'); print('2. إضافة مصروف'); print('3. عرض الملخص'); print('4. خروج'); String? choice = stdin.readLineSync(); switch (choice) { case '1': print('أدخل وصف الدخل:'); String? desc = stdin.readLineSync(); print('أدخل المبلغ:'); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({desc ?? 'دخل': amount}); print('تمت إضافة الدخل بنجاح.'); } else { print('المبلغ غير صالح!'); } break; case '2': print('أدخل وصف المصروف:'); String? desc = stdin.readLineSync(); print('أدخل المبلغ:'); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { expenseList.add({desc ?? 'مصروف': amount}); print('تمت إضافة المصروف بنجاح.'); } else { print('المبلغ غير صالح!'); } break; case '3': double totalIncome = incomeList.fold(0, (sum, item) => sum + item.values.first); double totalExpense = expenseList.fold(0, (sum, item) => sum + item.values.first); double netProfit = totalIncome - totalExpense; double tax = netProfit > 0 ? netProfit * 0.15 : 0; print('\n--- ملخص الميزانية ---'); print('إجمالي الدخل: \$${totalIncome.toStringAsFixed(2)}'); print('إجمالي المصروفات: \$${totalExpense.toStringAsFixed(2)}'); if (netProfit >= 0) { print('صافي الربح: \$${netProfit.toStringAsFixed(2)}'); print('الضريبة المستحقة (15%): \$${tax.toStringAsFixed(2)}'); } else { print('صافي الخسارة: \$${netProfit.abs().toStringAsFixed(2)}'); } break; case '4': print('تم الخروج من التطبيق.'); return; default: print('خيار غير صالح، حاول مرة أخرى.'); } } }