import 'dart:io'; const int MIN_TEMP = 15; const int MAX_TEMP = 30; void main() { bool lightsOn = false; int thermostatTemp = 20; bool securityArmed = false; print("Welcome to the Smart Home System!"); bool exitProgram = false; while (!exitProgram) { 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(); if (choice != null) { if (choice == '1') { lightsOn = !lightsOn; print("Lights are now ${lightsOn ? 'ON' : 'OFF'}.\n"); } else if (choice == '2') { bool validTemp = false; while (!validTemp) { stdout.write("Set thermostat temperature ($MIN_TEMP°C - $MAX_TEMP°C): "); String? tempInput = stdin.readLineSync(); if (tempInput != null) { int? temp = int.tryParse(tempInput); if (temp != null && temp >= MIN_TEMP && temp <= MAX_TEMP) { thermostatTemp = temp; print("Thermostat set to $thermostatTemp°C\n"); break; } else { print("Invalid temperature! Please enter a value between $MIN_TEMP and $MAX_TEMP."); } } } } else if (choice == '3') { securityArmed = !securityArmed; print("Security Armed Status is now ${securityArmed ? 'ON' : 'OFF'}.\n"); } else if (choice == '4') { print("\nSystem Status:"); print("- Lights: $lightsOn"); print("- Thermostat: $thermostatTemp °C "); print("- Security System: $securityArmed\n"); } else if (choice == '5') { exitProgram = true; print("Exiting the system. Goodbye!"); } else { print("Invalid choice! Please select 1-5."); } } } }