import 'dart:io'; void main() { print('💰 Welcome to Budget Management Application 💰'); List> incomeList = []; List> expenseList = []; while (true) { print('\nاختر خيارك:'); print('1. إضافة دخل'); print('2. إضافة مصروف'); print('3. عرض الملخص'); print('4. خروج'); stdout.write('أدخل رقم الخيار: '); String? input = stdin.readLineSync()?.trim(); switch (input) { case '1': addTransaction(incomeList, 'income'); break; case '2': addTransaction(expenseList, 'expense'); break; case '3': showSummary(incomeList, expenseList); break; case '4': print('الخروج من البرنامج. إلى اللقاء!'); return; default: print('خيار غير صالح. حاول مرة أخرى.'); } } } void addTransaction(List> list, String type) { stdout.write('أدخل وصف المبلغ: '); String? description = stdin.readLineSync()?.trim(); if (description == null || description.isEmpty) { description = 'No description'; } double? amount; while (true) { stdout.write('أدخل المبلغ (يجب أن يكون موجب): '); String? amtInput = stdin.readLineSync()?.trim(); amount = double.tryParse(amtInput ?? ''); if (amount != null && amount > 0) { break; } else { print('المبلغ غير صالح. حاول مرة أخرى.'); } } list.add({description: amount}); print('${type == "income" ? "الدخل" : "المصروف"} تمت إضافته: $description - $amount'); } void showSummary(List> incomeList, List> expenseList) { 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; print('\n--- ملخص الميزانية ---'); print('Total Income: $totalIncome'); print('Total Expense: $totalExpense'); if (netProfit > 0) { double tax = netProfit * 0.15; print('Your net profit is $netProfit'); print('Estimated tax (15%): $tax'); } else if (netProfit < 0) { print('Your net loss is ${-netProfit}'); } else { print('Break-even: no profit, no loss.'); } }