import 'dart:io'; void main() { double totalIncome = 0; double totalExpenses = 0; 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'); stdout.write('\nEnter your choice: '); String? choice = stdin.readLineSync(); switch (choice) { case '1': stdout.write('Enter income description: '); String? incomeDesc = stdin.readLineSync(); stdout.write('Enter income amount: '); double? incomeAmount = double.tryParse(stdin.readLineSync() ?? ''); if (incomeAmount != null && incomeAmount > 0) { totalIncome += incomeAmount; print('Income added!'); } else { print('Invalid amount. Please try again.'); } break; case '2': stdout.write('Enter expense description: '); String? expenseDesc = stdin.readLineSync(); stdout.write('Enter expense amount: '); double? expenseAmount = double.tryParse(stdin.readLineSync() ?? ''); if (expenseAmount != null && expenseAmount > 0) { totalExpenses += expenseAmount; print('Expense added!'); } else { print('Invalid amount. Please try again.'); } break; case '3': double netProfit = totalIncome - totalExpenses; double tax = 0; if (netProfit > 0) { tax = netProfit * 0.15; // 15% tax if profit } print('\nSummary:'); print('Total income: \$${totalIncome.toStringAsFixed(2)}'); print('Total expenses: \$${totalExpenses.toStringAsFixed(2)}'); print('Net profit: \$${netProfit.toStringAsFixed(2)}'); if (netProfit > 0) { print('Tax to be paid: \$${tax.toStringAsFixed(2)}'); } else if (netProfit == 0) { print('No profit or loss.'); } else { print('Loss: \$${(-netProfit).toStringAsFixed(2)}'); } break; case '4': print('\nExiting the application. Goodbye!'); return; default: print('Invalid choice. Please try again.'); } } }