import 'dart:io'; void main() { print("Welcome to the Smart Home System!"); smartHomeSystem(); } void smartHomeSystem() { bool lightsOn = false; int thermostat = 20; String securitySystem = "disarmed"; const int minTemp = 15; const int maxTemp = 30; while (true) { print("\nChoose an option:"); print("1. Toggle Lights"); print("2. Set Temperature"); print("3. Toggle Security System"); print("4. Show System Status"); print("5. Exit"); String? choice = stdin.readLineSync(); if (choice == "5") { print("Exiting the system."); break; } switch (choice) { case "1": lightsOn = !lightsOn; print("Lights turned ${lightsOn ? 'ON' : 'OFF'}."); break; case "2": print("Enter temperature between $minTemp and $maxTemp:"); int? temp = int.tryParse(stdin.readLineSync() ?? ""); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print("Temperature set to $thermostat°C."); } else { print("Invalid temperature. Try again."); } break; case "3": securitySystem = (securitySystem == "disarmed") ? "armed" : "disarmed"; print("Security system ${securitySystem == "armed" ? "activated" : "deactivated"}."); break; case "4": showStatus(lightsOn, thermostat, securitySystem); break; default: print("Invalid option. Try again."); } } } void showStatus(bool lights, int temp, String security) { String lightStatus = lights ? "ON" : "OFF"; String securityStatus = security.toUpperCase(); print("\n--- System Status ---"); print("Lights: $lightStatus"); print("Temperature: $temp°C"); if (temp % 3 == 0 && temp % 5 == 0) { print("Perfect Day"); } else if (temp % 3 == 0) { print("Cool Day"); } else if (temp % 5 == 0) { print("Warm Day"); } print("Security System: $securityStatus"); }