import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; String securityStatus = "disarmed"; bool isRunning = true; print(" === Assalamualaikum ==="); print("=== Smart home automation system ==="); while (isRunning) { print("\nChoose an option:"); print("1. Toggle Lights"); print("2. Set Thermostat"); 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) { print("Invalid input."); continue; } switch (choice) { case "1": lightsOn = !lightsOn; print("Lights are now ${lightsOn ? "ON" : "OFF"}."); break; case "2": stdout.write("Enter temperature ($minTemp - $maxTemp °C): "); String? tempInput = stdin.readLineSync(); if (tempInput != null) { int? newTemp = int.tryParse(tempInput); if (newTemp != null && newTemp >= minTemp && newTemp <= maxTemp) { thermostat = newTemp; print("Thermostat set to $thermostat°C."); } else { print("Invalid temperature. Please enter a value between $minTemp and $maxTemp."); } } break; case "3": if (securityStatus == "disarmed") { securityStatus = "armed"; } else { securityStatus = "disarmed"; } print("Security system is now ${securityStatus.toUpperCase()}."); break; case "4": print("\n=== System Status ==="); print("Lights: ${lightsOn ? "ON" : "OFF"}"); print("Thermostat: $thermostat°C"); print("Security System: ${securityStatus.toUpperCase()}"); if (thermostat % 3 == 0 && thermostat % 5 == 0) { print("Perfect Day 🌟 ($thermostat°C)"); } else if (thermostat % 3 == 0) { print("Cool Day ❄ ($thermostat°C)"); } else if (thermostat % 5 == 0) { print("Warm Day ☀ ($thermostat°C)"); } break; case "5": print("Exiting Smart Home System...Assalamualaikum "); isRunning = false; break; default: print("Invalid choice. Please select from 1 to 5."); } }}