import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print("======================================="); print(" Welcome to the Budget Management App "); print("=======================================\n"); 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': addIncome(incomeList); break; case '2': addExpense(expenseList); break; case '3': viewSummary(incomeList, expenseList); break; case '4': print("Exiting the application. Goodbye!"); isRunning = false; break; default: print("Invalid choice. Please try again."); } } } void addIncome(List> incomeList) { stdout.write("Enter income description: "); String? description = stdin.readLineSync(); stdout.write("Enter income amount: "); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount <= 0) { print("Invalid amount. Please enter a positive number."); return; } incomeList.add({description ?? "Unknown": amount}); print("Income added successfully!"); } void addExpense(List> expenseList) { stdout.write("Enter expense description: "); String? description = stdin.readLineSync(); stdout.write("Enter expense amount: "); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount == null || amount <= 0) { print("Invalid amount. Please enter a positive number."); return; } expenseList.add({description ?? "Unknown": amount}); print("Expense added successfully!"); } void viewSummary(List> incomeList, List> expenseList) { double totalIncome = 0; double totalExpenses = 0; for (var income in incomeList) { totalIncome += income.values.first; } for (var expense in expenseList) { totalExpenses += expense.values.first; } double net = totalIncome - totalExpenses; print("\n========== Summary =========="); print("Total income: \$${totalIncome.toStringAsFixed(2)}"); print("Total expenses: \$${totalExpenses.toStringAsFixed(2)}"); if (net > 0) { print("Net profit: \$${net.toStringAsFixed(2)}"); double tax = net * 0.15; print("Tax to be paid (15%): \$${tax.toStringAsFixed(2)}"); } else if (net < 0) { print("Net loss: \$${net.abs().toStringAsFixed(2)}"); print("No tax applied (business is at a loss)."); } else { print("Break-even: No profit, no loss."); } print("=============================\n"); }