import 'dart:io'; void main() { // Constants const int minTemp = 15; const int maxTemp = 30; // System states bool lightsOn = false; bool securityArmed = false; int thermostat = 20; int choice = 0; print("Welcome to the Smart Home System!"); while (choice != 5) { 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: "); choice = int.parse(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 temp = int.parse(stdin.readLineSync()!); if (temp >= minTemp && temp <= maxTemp) { thermostat = temp; print("Thermostat set to $thermostat°C."); } else { print("Invalid temperature! Must be 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: ${lightsOn ? "ON" : "OFF"}"); String weather; if (thermostat >= 25) { weather = "Warm Day"; } else if (thermostat <= 18) { weather = "Cold Day"; } else { weather = "Moderate"; } print("- Thermostat: $thermostat°C - $weather"); print("- Security System: ${securityArmed ? "ARMED" : "DISARMED"}"); break; case 5: print("Exiting the system. Goodbye!"); break; default: print("Invalid choice. Try again."); } } }