import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; bool isRunning = true; print(" === Assalamualaikum ==="); print("=== Budget Management Application ==="); while (isRunning) { print("\nChoose an option:"); print("1. Add Income"); print("2. Add Expense"); print("3. View Net Profit/Loss"); print("4. Exit"); stdout.write("Enter your choice: "); String? choice = stdin.readLineSync(); if (choice == null) { print("Invalid input."); continue; } if (choice == "1") { stdout.write("Enter income description: "); String? description = stdin.readLineSync(); stdout.write("Enter income amount: "); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ""); if (description != null && description.isNotEmpty && amount != null && amount >= 0) { incomeList.add({description: amount}); print("Income added successfully."); } else { print("Invalid income data. Amount must be a positive number."); } } else if (choice == "2") { stdout.write("Enter expense description: "); String? description = stdin.readLineSync(); stdout.write("Enter expense amount: "); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ""); if (description != null && description.isNotEmpty && amount != null && amount >= 0) { expenseList.add({description: amount}); print("Expense added successfully."); } else { print("Invalid expense data. Amount must be a 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 netProfit = totalIncome - totalExpenses; print("\n=== Budget Summary ==="); print("Total Income: \$${totalIncome}"); print("Total Expenses: \$${totalExpenses}"); if (netProfit > 0) { print("Your net profit is \$${netProfit}"); double tax = netProfit > 0 ? netProfit * 0.15 : 0; print("Tax to be paid (15%): \$${tax}"); } else if (netProfit < 0) { print("Your net loss is \$${netProfit.abs()}"); } else { print("You have broken even (no profit, no loss)."); } } else if (choice == "4") { print("Exiting Budget Management Application...Assalamualaikum"); isRunning = false; } else { print("Invalid choice. Please select from 1 to 4."); } }}