import 'dart:io'; void main(){ List> incomeList = []; List> expenseList = []; while(true){ int choice = int.parse(stdin.readLineSync()!); if(choice == 1){ String desc = stdin.readLineSync()!; double amount = double.parse(stdin.readLineSync()!); if(amount >= 0){ incomeList.add({desc: amount}); print("Income added!"); } else { print("Invalid amount"); } } else if(choice == 2){ String desc = stdin.readLineSync()!; double amount = double.parse(stdin.readLineSync()!); if(amount >= 0){ expenseList.add({desc: amount}); print("Expense added!"); } else { print("Invalid amount"); } } else if(choice == 3){ double totalIncome = 0; double totalExpense = 0; for(var item in incomeList){ totalIncome += item.values.first; } for(var item in expenseList){ totalExpense += item.values.first; } double net = totalIncome - totalExpense; print("Total income: $totalIncome"); print("Total expenses: $totalExpense"); if(net >= 0){ print("Net profit: $net"); } else { print("Net loss: ${net.abs()}"); } double tax = net > 0 ? net * 0.15 : 0; if(tax > 0){ print("Tax to be paid: $tax"); } } else if(choice == 4){ break; } } }