import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print("\nWelcome to the Budget Management Application!"); print("Please choose an option:"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit\n"); stdout.write("Enter your choice: "); String? choice = stdin.readLineSync(); switch (choice) { case '1': addIncome(incomeList); break; case '2': addExpense(expenseList); break; case '3': viewSummary(incomeList, expenseList); break; case '4': print("\nExiting the application. Goodbye!"); return; default: print("\nInvalid choice. Please try again."); } } } void addIncome(List> incomeList) { stdout.write("\nEnter income description: "); String? description = 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."); return; } incomeList.add({description!: amount}); print("Income added!"); } void addExpense(List> expenseList) { stdout.write("\nEnter expense description: "); String? description = 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."); return; } expenseList.add({description!: amount}); print("Expense added!"); } void viewSummary(List> incomeList, List> expenseList) { double totalIncome = 0; double totalExpenses = 0; for (var income in incomeList) { totalIncome += income.values.first; } for (var expense in expenseList) { totalExpenses += expense.values.first; } double netProfit = totalIncome - totalExpenses; print("\nSummary:"); print("Total income: \$${totalIncome}"); print("Total expenses: \$${totalExpenses}"); if (netProfit > 0) { double tax = netProfit * 0.15; print("Net profit: \$${netProfit}"); print("Tax to be paid: \$${tax}"); } else if (netProfit < 0) { print("Net loss: \$${netProfit.abs()}"); print("No tax applied due to loss."); } else { print("Break-even: No profit or loss."); print("No tax applied."); } }