import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; bool securityArmed = false; bool running = true; print("Welcome to the Smart Home System!"); while (running) { 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: "); int? choice = int.tryParse(stdin.readLineSync()!); if (choice == null) { print("Invalid input. Please enter a number."); continue; } switch (choice) { case 1: lightsOn = !lightsOn; if (lightsOn) { print("Lights are now ON."); } else { print("Lights are now OFF."); } break; case 2: stdout.write("Set thermostat temperature ($minTemp°C - $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 between $minTemp and $maxTemp."); } break; case 3: securityArmed = !securityArmed; if (securityArmed) { print("Security System ARMED."); } else { print("Security System DISARMED."); } break; case 4: print("\nSystem Status:"); String lightStatus = lightsOn ? "ON" : "OFF"; String securityStatus = securityArmed ? "ARMED" : "DISARMED"; String weatherMessage = ""; if (thermostat % 3 == 0 && thermostat % 5 == 0) { weatherMessage = "Perfect Day"; } else if (thermostat % 3 == 0) { weatherMessage = "Cool Day"; } else if (thermostat % 5 == 0) { weatherMessage = "Warm Day"; } print("- Lights: $lightStatus"); if (weatherMessage.isNotEmpty) { print("- Thermostat: $thermostat°C - $weatherMessage"); } else { print("- Thermostat: $thermostat°C"); } print("- Security System: $securityStatus"); break; case 5: print("Exiting the system. Goodbye!"); running = false; break; default: print("Invalid choice. Try again."); } } }