import 'dart:io'; void main() { // متغيرات الميزانية double totalIncome = 0.0; double totalExpenses = 0.0; print('Welcome to the Budget Management Application!'); bool isRunning = true; while (isRunning) { 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(); switch (choice) { case '1': // Add income stdout.write('Enter income description: '); String? description = stdin.readLineSync(); stdout.write('Enter income amount: '); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ''); if (amount == null || amount <= 0) { print('Invalid amount. Please enter a positive number.'); } else { totalIncome += amount; print('Income added!'); } break; case '2': // Add expense stdout.write('Enter expense description: '); String? description = stdin.readLineSync(); stdout.write('Enter expense amount: '); String? amountInput = stdin.readLineSync(); double? amount = double.tryParse(amountInput ?? ''); if (amount == null || amount <= 0) { print('Invalid amount. Please enter a positive number.'); } else { totalExpenses += amount; print('Expense added!'); } break; case '3': // View summary double netProfit = totalIncome - totalExpenses; double tax = netProfit > 0 ? netProfit * 0.15 : 0.0; // 15% tax print('\nSummary:'); print('Total income: \$${totalIncome.toStringAsFixed(2)}'); print('Total expenses: \$${totalExpenses.toStringAsFixed(2)}'); print('Net profit: \$${netProfit.toStringAsFixed(2)}'); print('Tax to be paid: \$${tax.toStringAsFixed(2)}'); break; case '4': isRunning = false; print('Exiting the application. Goodbye!'); break; default: print('Invalid choice. Please enter a number between 1 and 4.'); } } }