TaghreedAdel_243000607_question2.txt /** * Student Name: تغريد عادل * University ID: 243000607 * Question: 2 - Budget Management Application */ import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print('Welcome to the Budget Management Application, Taghreed!'); 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(); switch (choice) { case '1': stdout.write('Enter income description: '); String desc = stdin.readLineSync() ?? 'Income'; stdout.write('Enter income amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({desc: amount}); print('Income added successfully!'); } else { print('Invalid amount! No negative numbers allowed.'); } break; case '2': stdout.write('Enter expense description: '); String desc = stdin.readLineSync() ?? 'Expense'; stdout.write('Enter expense amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { expenseList.add({desc: amount}); print('Expense added successfully!'); } else { print('Invalid amount! No negative numbers allowed.'); } break; case '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 netProfit = totalIncome - totalExpenses; print('\n--- Financial Summary for Taghreed ---'); print('Total Income: \$${totalIncome.toStringAsFixed(2)}'); print('Total Expenses: \$${totalExpenses.toStringAsFixed(2)}'); if (netProfit >= 0) { print('Your net profit is \$${netProfit.toStringAsFixed(2)}'); } else { print('Your net loss is \$${netProfit.abs().toStringAsFixed(2)}'); } // حساب الضريبة باستخدام Ternary Operator double tax = (netProfit > 0) ? (netProfit * 0.15) : 0; if (netProfit > 0) { print('Tax to be paid (15%): \$${tax.toStringAsFixed(2)}'); } break; case '4': print('Exiting. Have a great day, Taghreed!'); return; default: print('Invalid option, please try again.'); } } }