import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; print("Welcome to the budget Management Application ! "); while (true) { print("Pleace choose an option : "); print("1. Add income"); print("2. Add expense "); print("3. View summary "); print("4. Exist"); print("Enter your choice :"); String? choice = stdin.readLineSync(); if (choice == "1") { print("Enter income description :"); String? desc = stdin.readLineSync(); choice = choice?.trim(); print("Enter income amount"); double amount = double.parse(stdin.readLineSync()!); if (amount < 0) { print("amount can not be negative !"); continue; } incomeList.add({desc!: amount}); print("Income added!"); } else if (choice == "2") { print("Enter expense decription :"); String? desc = stdin.readLineSync(); choice = choice?.trim(); print("Enter your amount :"); double amount = double.parse(stdin.readLineSync()!); if (amount < 0) { print("Amount can not be negative ! "); continue; } expenseList.add({desc!: amount}); print("Expense added !"); } else if (choice == "3") { double totalIncome = incomeList.fold( 0, (sum, item) => sum + item.values.first, ); double totalExpenses = expenseList.fold( 0, (sum, item) => sum + item.values.first, ); double net = totalIncome - totalExpenses; double tax = net > 0 ? net * 0.15 : 0; print(" Summary :"); print("Total income : \$${totalIncome}"); print("Total expenses : \$${totalExpenses}"); if (net >= 0) { print("Net profit : \$${net}"); print("Tax to be paid : \$${tax}"); } else { print("Net loss : \$${net.abs()}"); } } else if (choice == "4") { print("Exiting the application .Goodbye !"); break; } else { print("Invalid choice , please try again . "); } } }