void main() { List> incomeList = []; List> expenseList = []; print('Welcome to the Budget Management Application!'); while (true) { print('\nPlease choose an option:'); print('1. Add income'); print('2. Add expense'); print('3. View summary'); print('4. Exit'); 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('Exiting the application. Goodbye!'); return; default: print('Invalid choice. Please try again.'); } } } void addIncome(List> incomeList) { print('Enter income description:'); String? description = stdin.readLineSync(); print('Enter income amount:'); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput!); if (description != null && description.isNotEmpty && amount != null && amount > 0) { incomeList.add({ 'description': description, 'amount': amount }); print('Income added!'); } else { print('Invalid input. Please enter a valid description and positive amount.'); } } void addExpense(List> expenseList) { print('Enter expense description:'); String? description = stdin.readLineSync(); print('Enter expense amount:'); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput!); if (description != null && description.isNotEmpty && amount != null && amount > 0) { expenseList.add({ 'description': description, 'amount': amount }); print('Expense added!'); } else { print('Invalid input. Please enter a valid description and positive amount.'); } } void viewSummary(List> incomeList, List> expenseList) { double totalIncome = 0; double totalExpenses = 0; for (var income in incomeList) { totalIncome += income['amount']; } for (var expense in expenseList) { totalExpenses += expense['amount']; } double net = totalIncome - totalExpenses; print('\nSummary:'); print('Total income: \$${totalIncome.toStringAsFixed(2)}'); print('Total expenses: \$${totalExpenses.toStringAsFixed(2)}'); if (net >= 0) { print('Net profit: \$${net.toStringAsFixed(2)}'); double tax = net * 0.15; print('Tax to be paid: \$${tax.toStringAsFixed(2)}'); } else { print('Net loss: \$${net.abs().toStringAsFixed(2)}'); } }