// ======================================= // Budget Management Application // Developer: Ahmed Alawazim // Student ID: 2021204738 // ======================================= import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print('\n======================================='); print(' Welcome to the Budget Management Application! '); print(' Developer: Ahmed Alawazim'); print(' Student ID: 2021204738'); print('======================================='); print('Please choose an option:'); print('1. Add income'); print('2. Add expense'); print('3. View summary'); print('4. Exit'); stdout.write('\nEnter your choice: '); String? choice = stdin.readLineSync(); if (choice == '1') { // Add Income stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount < 0) { print('Invalid amount! Please enter a positive number.'); } else { incomeList.add({desc ?? 'Income': amount}); print('Income added successfully!'); } } else if (choice == '2') { // Add Expense stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount < 0) { print('Invalid amount! Please enter a positive number.'); } else { expenseList.add({desc ?? 'Expense': amount}); print('Expense added successfully!'); } } else if (choice == '3') { // View Summary double totalIncome = 0; double totalExpenses = 0; for (var i in incomeList) { i.forEach((key, value) => totalIncome += value); } for (var e in expenseList) { e.forEach((key, value) => totalExpenses += value); } 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)}'); // Optional Tax Feature double tax = net * 0.15; print('Tax to be paid (15%): \$${tax.toStringAsFixed(2)}'); print('Net profit after tax: \$${(net - tax).toStringAsFixed(2)}'); } else if (net < 0) { print('Your net loss is \$${net.abs().toStringAsFixed(2)}'); } else { print('You broke even — no profit or loss.'); } } else if (choice == '4') { print('Exiting Budget Management Application. Goodbye!'); break; } else { print('Invalid choice! Please enter a number between 1 and 4.'); } } }