import 'dart:io'; bool lightsOn = false; int thermostatTemp = 20; bool securityArmed = false; const int minTemp = 15; const int maxTemp = 30; void main() { print('Welcome to the Smart Home System!'); String? choice; do { displayMenu(); choice = stdin.readLineSync(); handleChoice(choice); } while (choice != '5'); } void displayMenu() { print('\nChoose an action:'); print('1. Toggle lights'); print('2. Set thermostat'); print('3. Arm/disarm security'); print('4. View status'); print('5. Exit'); stdout.write('Your choice: '); } void handleChoice(String? choice) { if (choice == null) return; if (choice == '1') { lightsOn = !lightsOn; print('Lights are now ${lightsOn ? 'ON' : 'OFF'}.'); } else if (choice == '2') { stdout.write('Enter temperature ($minTemp–$maxTemp): '); int? temp = int.tryParse(stdin.readLineSync() ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostatTemp = temp; print('Thermostat set to $thermostatTemp°C.'); } else { print('Invalid temperature.'); } } else if (choice == '3') { securityArmed = !securityArmed; print('Security system is now ${securityArmed ? 'ARMED' : 'DISARMED'}.'); } else if (choice == '4') { showStatus(); } else if (choice == '5') { print('Exiting system. Goodbye!'); } else { print('Invalid choice.'); } } void showStatus() { print('\n--- System Status ---'); print('Lights: ${lightsOn ? 'ON' : 'OFF'}'); print('Thermostat: $thermostatTemp°C'); print('Security: ${securityArmed ? 'ARMED' : 'DISARMED'}'); String message = ''; if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { message = 'Perfect Day'; } else if (thermostatTemp % 3 == 0) { message = 'Cool Day'; } else if (thermostatTemp % 5 == 0) { message = 'Warm Day'; } if (message.isNotEmpty) print(message); }