/* Budget Management Application ____________________________________ Sara Omar Ismail - 252000512 */ import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; bool exit = false; print("Welcome to the Budget Management Application!"); while (!exit) { print(""" --- MENUE --- Please choose an option: _________________________________ 1. Add income 2. Add expense 3. View summary 4. Exit _________________________________ Enter Your Choise:"""); String? user_choise = stdin.readLineSync(); switch (user_choise) { case "1": // handel add income bool income_amount_added = false; print("Enter income description "); String? income_description = stdin.readLineSync(); while (!income_amount_added) { print("Enter income amount "); String? input = stdin.readLineSync(); if (input == null || input.trim().isEmpty) { print("⚠️ income amount is requierd"); continue; } double? income_amount = double.tryParse(input); if (income_amount == null) { print("⚠️ Please Enter A vaild income ammount"); continue; } if (income_amount < 0) { print("⚠️ Income Amount Should be grater than 0"); continue; } incomeList.add({ income_description ?? "No Description": income_amount, }); income_amount_added = true; } print("✅ $income_description income ADDED"); break; case "2": // handel add expense bool expense_amount_added = false; print("Enter expense description "); String? expense_description = stdin.readLineSync(); while (!expense_amount_added) { print("Enter expense amount "); String? input = stdin.readLineSync(); if (input == null || input.trim().isEmpty) { print("⚠️ expense amount is requierd"); continue; } double? expense_amount = double.tryParse(input); if (expense_amount == null) { print("⚠️ Please Enter A vaild expense ammount"); continue; } if (expense_amount < 0) { print("⚠️ expense Amount Should be grater than 0"); continue; } expenseList.add({ expense_description ?? "No Description": expense_amount, }); expense_amount_added = true; } print("✅ $expense_description expense ADDED"); break; case "3": //handel View summary double total_income = incomeList.fold( 0.0, (sum, income) => sum + income.values.first, ); double total_expense = expenseList.fold( 0.0, (sum, expense) => sum + expense.values.first, ); double net = total_income - total_expense; String net_status = "profit"; bool tax_to_pay = true; if (total_expense > total_income) { net_status = "loss"; tax_to_pay = false; } print(""" Summary: Total income: $total_income Total expenses: $total_expense Net $net_status: $net """); if (tax_to_pay) { print(" 💵 Tax to be paid: ${0.15 * net}"); } break; case "4": // handel exit state exit = true; print("Exiting the system. Goodbye!"); break; default: print("Enter Valid Choise!"); } if (!exit) print("🚀 Going back to the main menu ....."); } }