import 'dart:io'; void main() { bool lightsOn = false; bool securityArmed = false; int thermostat = 20; const int minTemp = 15; const int maxTemp = 30; while (true) { print('\nWelcome to the Smart Home System!'); print('Please 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? choice = stdin.readLineSync(); switch (choice) { case "1": // Toggle lights on/off lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}'); break; case "2": // Set thermostat temperature stdout.write('Set thermostat temperature (15°C to 30°C): '); String? tempInput = stdin.readLineSync(); int? temp = int.tryParse(tempInput!); if (temp == null temp < minTemp temp > maxTemp) { print('Invalid temperature! Please enter a value between 15°C and 30°C.'); } else { thermostat = temp; print('Thermostat is set to $thermostat°C.'); } break; case "3": // Arm or disarm the security system securityArmed = !securityArmed; print('Security System is now ${securityArmed ? "ARMED" : "DISARMED"}'); break; case "4": // View system status String tempMessage = (thermostat > 24) ? "Warm Day" : "Cool Day"; print("\nSystem Status:"); print('Lights: ${lightsOn ? "ON" : "OFF"}'); print('Thermostat: $thermostat°C'); print('Security System: ${securityArmed ? "ARMED" : "DISARMED"}'); print('Today is a $tempMessage.'); break; case "5": // Exit the program print('Exiting the Smart Home System. Goodbye!'); return; default: print('Invalid option. Please choose a valid number between 1 and 5.'); } } }