import 'dart:io'; void main(){ print("Welcome to the Budget Management Application!"); List> incomeList = []; List> expenseList = []; bool managingBudget = true; print("Please choose an option:"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit"); while(managingBudget){ stdout.write("\nEnter your choice: "); String? choice = stdin.readLineSync(); if (choice == '1') { stdout.write('Enter income description: '); String? description = stdin.readLineSync(); stdout.write('Enter income amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({description ?? 'Unknown': amount}); print('Income added!'); } else { print('Invalid amount. Please enter a positive number.'); } } if (choice == '2') { stdout.write('Enter expense description: '); String? description = stdin.readLineSync(); stdout.write('Enter expense amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { expenseList.add({description ?? 'Unknown': amount}); print('Expense added!'); } else { print('Invalid amount. Please enter a positive number.'); } } if (choice == '3') { double totalIncome = 0; double totalExpenses = 0; for (var entry in incomeList) { totalIncome += entry.values.first; } for (var entry in expenseList) { totalExpenses += entry.values.first; } double net = totalIncome - totalExpenses; print('Summary:'); print('Total income: \$${totalIncome.toStringAsFixed(0)}'); print('Total expenses: \$${totalExpenses.toStringAsFixed(0)}'); if (net >= 0) { print('Net profit: \$${net.toStringAsFixed(0)}'); double tax = net * 0.15; print('Tax to be paid: \$${tax.toStringAsFixed(0)}'); } else { print('Net loss: \$${net.toStringAsFixed(0)}'); } } if (choice == '4') { print('Exiting the application. Goodbye!'); managingBudget = false; } if (choice != '1' && choice != '2' && choice != '3' && choice != '4') { print('Invalid choice. Please try again.'); } } }