import 'dart:io'; void main() { double totalIncome = 0; double totalExpenses = 0; while (true) { print("\nBudget Manager"); print("1. Add Income"); print("2. Add Expense"); print("3. Show Summary"); print("4. Exit"); stdout.write("Enter your choice: "); String? choice = stdin.readLineSync(); if (choice == '1') { stdout.write("Enter income amount: "); double? amount = double.tryParse(stdin.readLineSync()!); if (amount != null && amount > 0) { totalIncome += amount; print("Income added."); } else { print("Invalid amount."); } } else if (choice == '2') { stdout.write("Enter expense amount: "); double? amount = double.tryParse(stdin.readLineSync()!); if (amount != null && amount > 0) { totalExpenses += amount; print("Expense added."); } else { print("Invalid amount."); } } else if (choice == '3') { double netBalance = totalIncome - totalExpenses; print("\nSummary:"); print("Total Income: \$${totalIncome.toStringAsFixed(2)}"); print("Total Expenses: \$${totalExpenses.toStringAsFixed(2)}"); print("Net Balance: \$${netBalance.toStringAsFixed(2)}"); } else if (choice == '4') { print("Goodbye!"); break; } else { print("Invalid choice, try again."); } } }