import 'dart:io'; void main() { print("Welcome to the budget management Application!\n"); List> incomelist = []; List> expenselist = []; bool task = true; while (task) { print("\nPlease choose an option:\n"); print("1. Add income"); print("2. Add expense"); print("3. View summary"); print("4. Exit\n"); print("Enter your choice:\n"); String? input = stdin.readLineSync(); int? choice = int.tryParse(input ?? ''); if (choice == null) { print("invalid input:\nPlease enter a number 1-4.\n"); continue; } switch (choice) { case 1: print("Enter income description: ."); String? description = stdin.readLineSync(); description = (description == null || description.trim().isEmpty) ? " income" : description.trim(); print("Enter income amount:"); String? amounttext = stdin.readLineSync(); double? amount = double.tryParse(amounttext ?? ''); if (amount == null || amount < 0) { print("invalid amount. please enter a positive number."); } else { incomelist.add({description: amount}); print("income added! \n"); } break; case 2: print("Enter expense dascription."); String? dascription1 = stdin.readLineSync(); dascription1 = (dascription1 == null || dascription1.trim().isEmpty) ? "Expense" : dascription1.trim(); print("Enter expense amount."); String? amounttext = stdin.readLineSync(); double? amount1 = double.tryParse(amounttext ?? ''); if (amount1 == null || amount1 < 0) { print("invalid amount.please enter a positive number."); } else { expenselist.add({dascription1: amount1}); print("Expense added! \n"); } break; case 3: print("summary.\n"); double total_income = 0; for (var item in incomelist) { total_income += item.values.first; } double total_expeses = 0; for (var item in expenselist) { total_expeses += item.values.first; } double net = total_income - total_expeses; double tax = net > 0 ? net * 0.15 : 0; print("total income: \$${total_income}"); print("total expenses: \$${total_expeses}"); if (net >= 0) { print("net profit. \$${net}"); print("tax to be paid. \$${tax}"); } else { print("net loss. \$${-net}"); print("tax to be paid. \$0"); } break; case 4: print("\nExiting the application. Googbye!\n"); task = false; break; default: print("Please enter a number 1-4.\n"); } } }