import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightOn = false; int thermostat = 20; bool securityArmed = false; 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(); if (choice == "5") { print("Exiting the system. Goodbye!"); break; } switch (choice) { case "1": lightOn = !lightOn; print("Lights are now ${lightOn ? "ON" : "OFF"}."); break; case "2": stdout.write("Set thermostat temperature ($minTemp-$maxTemp C): "); 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! Please enter a value between $minTemp and $maxTemp."); } break; case "3": securityArmed = !securityArmed; print( "Security System is now ${securityArmed ? "ARMED" : "DISARMED"}."); break; case "4": print("\nSystem Status:"); print("Lights: ${lightOn ? "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"); String securityStatus = securityArmed ? "ARMED" : "DISARMED"; print("Security System: $securityStatus"); break; default: print("Invalid choice! Please try again."); } } }