import 'dart:io'; const int MIN_TEMP = 15; const int MAX_TEMP = 30; bool lightsOn = false; int temperature = 20; bool securityArmed = false; void toggleLights() { lightsOn = !lightsOn; if (lightsOn == true) { print("Lights are now ON."); } else { print("Lights are now OFF."); } } void setThermostat() { stdout.write("Set temperature (${MIN_TEMP}°C - ${MAX_TEMP}°C): "); String? input = stdin.readLineSync(); int? temp = int.tryParse(input ?? ''); if (temp != null) { if (temp >= MIN_TEMP && temp <= MAX_TEMP) { temperature = temp; print("Thermostat set to ${temperature}°C."); } else { print("Error: Temperature must be between $MIN_TEMP°C and $MAX_TEMP°C."); } } else { print("Invalid input. Please enter a number."); } } void toggleSecurity() { securityArmed = !securityArmed; if (securityArmed) { print("Security system is now ARMED."); } else { print("Security system is now DISARMED."); } } void displayStatus() { print("\n--- Current System Status ---"); print("Lights: ${lightsOn ? 'ON' : 'OFF'}"); print("Security System: ${securityArmed ? 'ARMED' : 'DISARMED'}"); String dayMessage = ""; if (temperature % 3 == 0 && temperature % 5 == 0) { dayMessage = "Perfect Day"; } else if (temperature % 5 == 0) { dayMessage = "Warm Day"; } else if (temperature % 3 == 0) { dayMessage = "Cool Day"; } print("Thermostat: ${temperature}°C ${dayMessage.isNotEmpty ? '($dayMessage)' : ''}"); } void main() { print("Welcome to the Smart Home System!"); 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? choice = stdin.readLineSync(); switch (choice) { case '1': toggleLights(); break; case '2': setThermostat(); break; case '3': toggleSecurity(); break; case '4': displayStatus(); break; case '5': print("Exiting the system. Goodbye!"); return; default: print("Invalid choice. Please enter a number between 1 and 5."); } } }