============================== Smart Home Automation (Dart) ============================== import 'dart:io'; void main() { SmartHome home = SmartHome(); home.start(); } class SmartHome { bool lightsOn = false; int temperature = 20; bool securityArmed = false; static const int minTemp = 15; static const int maxTemp = 30; void start() { while (true) { print('\n--- Smart Home Menu ---'); print('1. Toggle Lights'); print('2. Set Thermostat'); print('3. Arm/Disarm Security'); print('4. View Status'); print('5. Exit'); stdout.write('Choose an option: '); String? choice = stdin.readLineSync(); switch (choice) { case '1': lightsOn = !lightsOn; print('Lights are now \${lightsOn ? "ON" : "OFF"}'); break; case '2': setTemperature(); break; case '3': securityArmed = !securityArmed; print('Security system is now \${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': showStatus(); break; case '5': print('Exiting... Goodbye!'); return; default: print('Invalid choice!'); } } } void setTemperature() { stdout.write('Enter temperature (15–30): '); int? temp = int.tryParse(stdin.readLineSync() ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { temperature = temp; print('Temperature set to \$temperature°C'); } else { print('Invalid temperature!'); } } void showStatus() { String lightStatus = lightsOn ? "ON" : "OFF"; String secStatus = securityArmed ? "ARMED" : "DISARMED"; String mood = ''; if (temperature % 3 == 0 && temperature % 5 == 0) mood = 'Perfect Day'; else if (temperature % 3 == 0) mood = 'Cool Day'; else if (temperature % 5 == 0) mood = 'Warm Day'; print('\n--- System Status ---'); print('Lights: \$lightStatus'); print('Thermostat: \$temperature°C \$mood'); print('Security: \${secStatus.toUpperCase()}'); } } ============================== Budget Management (Dart) ============================== import 'dart:io'; void main() { List> incomeList = []; List> expenseList = []; while (true) { print('\n--- Budget Menu ---'); print('1. Add Income'); print('2. Add Expense'); print('3. View Summary'); print('4. Exit'); stdout.write('Choose an option: '); String? choice = stdin.readLineSync(); if (choice == '1') { stdout.write('Enter income description: '); String? desc = stdin.readLineSync(); stdout.write('Enter amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { incomeList.add({desc ?? '': amount}); print('Income added.'); } else { print('Invalid amount!'); } } else if (choice == '2') { stdout.write('Enter expense description: '); String? desc = stdin.readLineSync(); stdout.write('Enter amount: '); double? amount = double.tryParse(stdin.readLineSync() ?? ''); if (amount != null && amount > 0) { expenseList.add({desc ?? '': amount}); print('Expense added.'); } else { print('Invalid amount!'); } } else if (choice == '3') { double totalIncome = incomeList.fold(0, (sum, item) => sum + item.values.first); double totalExpenses = expenseList.fold(0, (sum, item) => sum + item.values.first); double net = totalIncome - totalExpenses; print('\n--- Summary ---'); print('Total Income: \$\$totalIncome'); print('Total Expenses: \$\$totalExpenses'); if (net >= 0) { print('Net Profit: \$\$net'); double tax = net > 0 ? net * 0.15 : 0; print('Tax to pay: \$\${tax.toStringAsFixed(2)}'); } else { print('Net Loss: \$\${net.abs()}'); } } else if (choice == '4') { print('Goodbye!'); break; } else { print('Invalid choice!'); } } }