import 'dart:io'; void main() { print("=== SIMPLE BUDGET MANAGEMENT SYSTEM ==="); // Lists to store income and expenses List> incomeList = []; List> expenseList = []; while (true) { print("\nChoose 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(); if (choice == null) continue; if (choice == "4") { print("Exiting Budget System. Goodbye!"); break; } if (choice == "1") { // Add Income stdout.write("Enter income description: "); String? desc = 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 { incomeList.add({desc ?? "Income": amount}); print("Income added successfully."); } } else if (choice == "2") { // Add Expense stdout.write("Enter expense description: "); String? desc = 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 { expenseList.add({desc ?? "Expense": amount}); print("Expense added successfully."); } } else if (choice == "3") { // View Summary double totalIncome = 0; double totalExpenses = 0; for (var item in incomeList) { totalIncome += item.values.first; } for (var item in expenseList) { totalExpenses += item.values.first; } double net = totalIncome - totalExpenses; print("\n--- BUDGET SUMMARY ---"); print("Total Income: \$${totalIncome.toStringAsFixed(2)}"); print("Total Expenses: \$${totalExpenses.toStringAsFixed(2)}"); if (net > 0) { print("Your net profit is \$${net.toStringAsFixed(2)}"); // Optional Tax Calculation (15%) double tax = net > 0 ? net * 0.15 : 0; print("Tax to be paid (15%): \$${tax.toStringAsFixed(2)}"); } else if (net < 0) { print("Your net loss is \$${net.abs().toStringAsFixed(2)}"); } else { print("You broke even this month."); } } else { print("Invalid choice. Please select a valid option."); } } }