import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; bool securityArmed = false; while (true) { print("\n=== Smart Home System ==="); print("1. Control Lights"); print("2. Set Thermostat"); print("3. Control Security System"); print("4. View System Status"); print("5. Exit"); stdout.write("Choose an option: "); String? choice = stdin.readLineSync(); if (choice == "5") { print("Exiting system..."); break; } switch (choice) { case "1": lightsOn = !lightsOn; print("Lights are now ${lightsOn ? "ON" : "OFF"}"); break; case "2": stdout.write("Enter temperature ($minTemp - $maxTemp): "); int? temp = int.tryParse(stdin.readLineSync() ?? ""); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print("Thermostat set to $thermostat°C"); } else { print("Invalid temperature! Try again."); } break; case "3": securityArmed = !securityArmed; print("Security System is now ${securityArmed ? "ARMED" : "DISARMED"}"); break; case "4": String lightStatus = lightsOn ? "ON" : "OFF"; String securityStatus = (securityArmed ? "armed" : "disarmed").toUpperCase(); print("\n--- System Status ---"); print("Lights: $lightStatus"); print("Thermostat: $thermostat°C"); print("Security System: $securityStatus"); if (thermostat % 3 == 0 && thermostat % 5 == 0) { print("Perfect Day 🌤"); } else if (thermostat % 3 == 0) { print("Cool Day ❄"); } else if (thermostat % 5 == 0) { print("Warm Day ☀"); } break; default: print("Invalid choice!"); } } }