import 'dart:io'; void main() { Map income = {}; Map expenses = {}; while (true) { print('\nPlease choose an option:'); print('1. Add income'); print('2. Add expense'); print('3. View summary'); print('4. Exit'); stdout.write('Enter your choice: '); String? choice = stdin.readLineSync(); if (choice == '1') { stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount: '); double amount = double.parse(stdin.readLineSync()!); income[desc!] = amount; print('Income added!'); } else if (choice == '2') { stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount: '); double amount = double.parse(stdin.readLineSync()!); expenses[desc!] = amount; print('Expense added!'); } else if (choice == '3') { double totalIncome = 0; double totalExpenses = 0; for (var inc in income.entries) { totalIncome += inc.value; } for (var exp in expenses.entries) { totalExpenses += exp.value; } double netProfit = totalIncome - totalExpenses; double tax = netProfit > 0 ? netProfit * 0.15 : 0; print('\nSummary:'); print('Total income: \$${totalIncome.toStringAsFixed(2)}'); print('Total expenses: \$${totalExpenses.toStringAsFixed(2)}'); if (netProfit >= 0) { print('Net profit: \$${netProfit.toStringAsFixed(2)}'); print('Tax to be paid: \$${tax.toStringAsFixed(2)}'); } else { print('Net loss: \$${netProfit.abs().toStringAsFixed(2)}'); } } else if (choice == '4') { print('Exiting the application. Goodbye!'); break; } else { print('Invalid option. Please choose 1, 2, 3, or 4.'); } } }