import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print('\nThe Budget Mangement Application! \n Choose an option :'); print('1. Add Income'); print('2. Add Expense'); print('3. View Summary'); print('4. Exit'); stdout.write('Enter Choose : '); String? choice = stdin.readLineSync(); if (choice == '1') { stdout.write('Enter income description : '); String? desc = stdin.readLineSync(); stdout.write('Enter income amount : '); String? input = stdin.readLineSync(); double? amount = double.tryParse(input ?? ''); if (amount != null && amount > 0) { incomeList.add({desc ?? 'income': amount}); print('Income added!'); } else { print('Invaild amount.'); } } else if (choice == '2') { stdout.write('Enter expense description : '); String? desc = stdin.readLineSync(); stdout.write('Enter expense amount : '); String? input = stdin.readLineSync(); double? amount = double.tryParse(input ?? ''); if (amount != null && amount > 0) { expenseList.add({desc ?? 'Expense': amount}); print('Expense added!'); } else { print('Invaild amount.'); } } else if (choice == '3') { double totalIncome = 0; double totalExpense = 0; for (var i in incomeList) { totalIncome += i.values.first; } for (var e in expenseList) { totalExpense += e.values.first; } double net = totalIncome - totalExpense; print('\nSummary :'); print('Total Income : \$${totalIncome.toStringAsFixed(2)}'); print('Total Expense : \$${totalExpense.toStringAsFixed(2)}'); if (net > 0) { double tax = net * 0.15; print('Net Profit : \$${net.toStringAsFixed(2)}'); print('Tax (15%) : \$${tax.toStringAsFixed(2)}'); } else if (net < 0) { print('Net Loss : \$${net.abs().toStringAsFixed(2)}'); } else { print('No profit or loss.'); } } else if (choice == '4') { print('Exiting The Application. \n Goodbye!'); return; } else { print('Invaild choice.'); } } }