// Budget Management Application - Dart Program // Student: Hadeel Bin Omar // ID: 123456789 import 'dart:io'; void main() { print('=============================='); print(' Welcome to Budget Manager '); print('=============================='); // 🔹 القوائم لتخزين الدخل والمصاريف List> incomeList = []; List> expenseList = []; 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? choice = stdin.readLineSync(); if (choice == null) continue; if (choice == '1') { // 🟩 إضافة دخل stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount: '); String? amtInput = stdin.readLineSync(); double? amount = double.tryParse(amtInput ?? ''); if (desc != null && amount != null && amount >= 0) { incomeList.add({desc: amount}); print('✅ Income added successfully.'); } else { print('❌ Invalid input! Please enter a valid positive number.'); } } else if (choice == '2') { // 🟥 إضافة مصروف stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount: '); String? amtInput = stdin.readLineSync(); double? amount = double.tryParse(amtInput ?? ''); if (desc != null && amount != null && amount >= 0) { expenseList.add({desc: amount}); print('✅ Expense added successfully.'); } else { print('❌ Invalid input! Please enter a valid positive number.'); } } else if (choice == '3') { // 📊 عرض الملخص double totalIncome = 0; double totalExpenses = 0; for (var item in incomeList) { totalIncome += item.values.first; } for (var item in expenseList) { totalExpenses += item.values.first; } double net = totalIncome - totalExpenses; print('\n========== 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.15; print('Tax to be paid (15%): \$${tax.toStringAsFixed(2)}'); } else if (net < 0) { print('Your net loss is \$${net.abs().toStringAsFixed(2)}'); } else { print('You broke even this month!'); } print('=============================='); } else if (choice == '4') { // 🚪 الخروج من البرنامج print('Exiting Budget Manager... Goodbye!'); break; } else { print('❌ Invalid choice! Please select 1–4.'); } } }