Fatimaalkoud_242002338_question2. // Exam 3 - Question 2 // Budget Management Application // Student Name: Fatima Alkoud // University ID: 242002338 import 'dart:io'; void main() { // Lists to store income and expenses List> incomeList = []; List> expenseList = []; bool running = true; print("Welcome to Budget Management Application"); // Main loop while (running) { print("\n--- Budget Menu ---"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit"); String? choice = stdin.readLineSync(); // Handle menu options using if/else if (choice == '1') { print("Enter income description:"); String? description = stdin.readLineSync(); print("Enter income amount:"); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ""); // Validate positive amount if (amount != null && amount > 0) { incomeList.add({ description ?? "Unknown": amount }); print("Income added successfully."); } else { print("Invalid amount. Please enter a positive number."); } } else if (choice == '2') { print("Enter expense description:"); String? description = stdin.readLineSync(); print("Enter expense amount:"); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ""); // Validate positive amount if (amount != null && amount > 0) { expenseList.add({ description ?? "Unknown": amount }); print("Expense added successfully."); } else { print("Invalid amount. Please enter a positive number."); } } else if (choice == '3') { double totalIncome = 0; double totalExpense = 0; // Calculate total income for (var item in incomeList) { totalIncome += item.values.first; } // Calculate total expenses for (var item in expenseList) { totalExpense += item.values.first; } double netResult = totalIncome - totalExpense; print("\n--- Budget Summary ---"); print("Total Income: \$${totalIncome}"); print("Total Expenses: \$${totalExpense}"); if (netResult > 0) { print("Your net profit is \$${netResult}"); // Calculate 15% tax only if there is profit (ternary operator) double tax = netResult > 0 ? netResult * 0.15 : 0; print("Tax to be paid (15%): \$${tax}"); } else if (netResult < 0) { print("Your net loss is \$${netResult.abs()}"); } else { print("You broke even. No profit, no loss."); } } else if (choice == '4') { running = false; print("Exiting application. Goodbye!"); } else { print("Invalid option. Please try again."); } } }