import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; String securitySystem = "disarmed"; 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": lightsOn = !lightsOn; print("Lights are now ${lightsOn ? "ON" : "OFF"}."); break; case "2": stdout.write("Set thermostat temperature ($minTemp°C - $maxTemp°C): "); int? newTemp = int.tryParse(stdin.readLineSync()!); if (newTemp == null || newTemp < minTemp || newTemp > maxTemp) { print("Invalid temperature! Please enter a value between $minTemp and $maxTemp."); } else { thermostat = newTemp; print("Thermostat set to $thermostat°C."); } break; case "3": securitySystem = (securitySystem == "disarmed") ? "armed" : "disarmed"; print("Security system is now ${securitySystem.toUpperCase()}."); break; case "4": print("\nSystem Status:"); print("- Lights: ${lightsOn ? "ON" : "OFF"}"); String dayMessage = ""; if (thermostat % 3 == 0 && thermostat % 5 == 0) { dayMessage = "Perfect Day"; } else if (thermostat % 3 == 0) { dayMessage = "Cool Day"; } else if (thermostat % 5 == 0) { dayMessage = "Warm Day"; } print("- Thermostat: $thermostat°C ${dayMessage.isNotEmpty ? "- $dayMessage" : ""}"); print("- Security System: ${securitySystem.toUpperCase()}"); break; case "5": print("Exiting the system. Goodbye!"); return; default: print("Invalid choice. Please try again."); } } }