// Smart Home Automation Code import 'dart:io'; void main() { // Initial device statuses bool lightsOn = false; double thermostatTemp = 20.0; bool securityArmed = false; // Constants for temperature range const double minTemp = 15.0; const double maxTemp = 30.0; print('Welcome to the Smart Home System!'); // Main loop for user interaction while (true) { print('\nPlease choose an action:'); print('1. Toggle lights'); print('2. Set thermostat temperature'); print('3. Arm/disarm security system'); print('4. View system status'); print('5. Exit'); stdout.write('Enter your choice: '); String? input = stdin.readLineSync(); if (input == null) { print('Invalid input. Please try again.'); continue; } int? choice = int.tryParse(input); if (choice == null) { print('Invalid input. Please enter a number.'); continue; } switch (choice) { case 1: lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.'); break; case 2: stdout.write('Set thermostat temperature (${minTemp}°C - ${maxTemp}°C): '); String? tempInput = stdin.readLineSync(); if (tempInput == null) { print('Invalid input. Please try again.'); continue; } double? newTemp = double.tryParse(tempInput); if (newTemp == null) { print('Invalid temperature. Please enter a number.'); } else if (newTemp >= minTemp && newTemp <= maxTemp) { thermostatTemp = newTemp; print('Thermostat set to ${thermostatTemp}°C.'); } else { print('Temperature must be between ${minTemp}°C and ${maxTemp}°C.'); } break; case 3: securityArmed = !securityArmed; print('Security System: ${securityArmed ? "ARMED" : "DISARMED"}.'); break; case 4: print('\nSystem Status:'); print('- Lights: ${lightsOn ? "ON" : "OFF"}'); String tempStatus = '- Thermostat: ${thermostatTemp}°C'; if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { tempStatus += ' - Perfect Day'; } else if (thermostatTemp % 3 == 0) { tempStatus += ' - Cool Day'; } else if (thermostatTemp % 5 == 0) { tempStatus += ' - Warm Day'; } print(tempStatus); print('- Security System: ${securityArmed ? "ARMED" : "DISARMED"}'); break; case 5: print('Exiting the system. Goodbye!'); return; default: print('Invalid choice. Please select a valid option.'); } } }