import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; const double taxRate = 0.15; print('💰 Welcome to Budget Management Application'); bool running = true; while (running) { print('\nSelect an option:'); print('1. Add Income'); print('2. Add Expense'); print('3. View Summary'); print('4. Exit'); stdout.write('Your choice: '); String? choice = stdin.readLineSync(); switch (choice) { case '1': stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount: '); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ''); if (desc != null && amount != null && amount >= 0) { incomeList.add({desc: amount}); print('✅ Income added: $desc - \$${amount.toStringAsFixed(2)}'); } else { print('❌ Invalid input. Please enter a valid description and a positive amount.'); } break; case '2': stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount: '); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ''); if (desc != null && amount != null && amount >= 0) { expenseList.add({desc: amount}); print('✅ Expense added: $desc - \$${amount.toStringAsFixed(2)}'); } else { print('❌ Invalid input. Please enter a valid description and a positive amount.'); } break; case '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('\n--- Budget Summary ---'); print('Total Income: \$${totalIncome.toStringAsFixed(2)}'); print('Total Expenses: \$${totalExpenses.toStringAsFixed(2)}'); print(net >= 0 ? 'Your net profit is \$${net.toStringAsFixed(2)}' : 'Your net loss is \$${(-net).toStringAsFixed(2)}'); // Optional Tax Calculation double tax = net > 0 ? net * taxRate : 0; if (tax > 0) { print('Tax to be paid (15% of net profit): \$${tax.toStringAsFixed(2)}'); } break; case '4': running = false; print('👋 Exiting Budget Management Application. Goodbye!'); break; default: print('❌ Invalid option. Please select between 1–4.'); } } }