/*__scenario(2)__ 1- Addincome: The program should prompt the user to enter the income description and amount. 2- Addexpense: The program should prompt the user to enter the expense description and amount. 3- Viewnetprofit or loss: The program should calculate the total income, total expenses, and display the net profit (income- expenses) or net loss (if expenses exceed income). 3- Exit: The user should be able to exit the program.*/ import 'dart:io'; void main() { // Lists to store income and expense entries List> incomeList = []; List> expenseList = []; print("======================================"); print(" Welcome to Budget Manager App "); print("======================================"); bool isRunning = true; while (isRunning) { print("\nChoose an option:"); print("1. Add Income"); print("2. Add Expense"); print("3. View Summary"); print("4. Exit"); stdout.write("Enter your choice (1-4): "); String? choice = stdin.readLineSync(); if (choice == "1") { // Add Income stdout.write("Enter income description: "); String? description = stdin.readLineSync(); stdout.write("Enter income amount: "); double? amount = double.tryParse(stdin.readLineSync()!); // Input validation if (amount != null && amount > 0) { incomeList.add({ "description": description ?? "No description", "amount": amount }); print("Income added successfully!"); } else { print("Invalid amount! Please enter a positive number."); } } else if (choice == "2") { // Add Expense stdout.write("Enter expense description: "); String? description = stdin.readLineSync(); stdout.write("Enter expense amount: "); double? amount = double.tryParse(stdin.readLineSync()!); // Input validation if (amount != null && amount > 0) { expenseList.add({ "description": description ?? "No description", "amount": amount }); print("Expense added successfully!"); } else { print("Invalid amount! Please enter a positive number."); } } else if (choice == "3") { // View Summary double totalIncome = 0; double totalExpenses = 0; for (var income in incomeList) { totalIncome += income["amount"]; } for (var expense in expenseList) { totalExpenses += expense["amount"]; } double net = totalIncome - totalExpenses; print("\n===== Monthly 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)}"); print("No tax is required due to loss."); } else { print("You broke even this month."); } } else if (choice == "4") { print("Thank you for using Budget Manager App!...GB"); isRunning = false; } else { print("Invalid choice! Please select between 1 and 4."); } } }