import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; void main() { bool lightsOn = 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(); 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): "); String? input = stdin.readLineSync(); int? temp = int.tryParse(input ?? ""); 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; String statusMsg = securityArmed ? "armed" : "disarmed"; print("Security system is now ${statusMsg.toUpperCase()}."); break; case "4": String lightsStatus = lightsOn ? "on" : "off"; String securityStatus = securityArmed ? "armed" : "disarmed"; String dayStatus = ""; if (thermostat % 3 == 0 && thermostat % 5 == 0) { dayStatus = "Perfect Day"; } else if (thermostat % 3 == 0) { dayStatus = "Cool Day"; } else if (thermostat % 5 == 0) { dayStatus = "Warm Day"; } print("\nSystem Status:"); print("- Lights: ${lightsStatus.toUpperCase()}"); print("- Thermostat: $thermostat°C${dayStatus.isNotEmpty ? " - $dayStatus" : ""}"); print("- Security System: ${securityStatus.toUpperCase()}"); break; case "5": print("Exiting the system. Goodbye!"); return; default: print("Invalid choice. Please try again."); } } }