import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print('===== Welcome to Budget Management App ====='); while (true) { print('\n1. Add Income'); print('2. Add Expense'); print('3. View Summary'); print('4. Exit'); stdout.write('Choose an option: '); String? choice = stdin.readLineSync(); if (choice == '4') { print('Exiting Budget Management App. Goodbye!'); break; } switch (choice) { case '1': stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({desc ?? 'Unnamed Income': amount}); print('Income added successfully.'); } else { print('Invalid amount! Please enter a positive number.'); } break; case '2': stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { expenseList.add({desc ?? 'Unnamed Expense': amount}); print('Expense added successfully.'); } else { print('Invalid amount! Please enter a positive number.'); } 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)}'); if (net > 0) { double tax = net * 0.15; print('Your net profit is \$${net.toStringAsFixed(2)}'); print('Tax to be paid (15%): \$${tax.toStringAsFixed(2)}'); } else if (net < 0) { print('Your net loss is \$${(-net).toStringAsFixed(2)}'); } else { print('You broke even — no profit or loss.'); } break; default: print('Invalid choice! Please select a valid option.'); } } }