import 'dart:io'; // Constant temperature limits const int minTemp = 15; const int maxTemp = 30; void main() { // Initial device states bool lightsOn = false; int thermostat = 20; bool securityArmed = false; print("=== SMART HOME AUTOMATION SYSTEM ==="); while (true) { print("\nChoose an option:"); 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 == null) continue; if (choice == "5") { print("Exiting Smart Home System. Goodbye!"); break; } switch (choice) { case "1": lightsOn = !lightsOn; print("Lights have been turned ${lightsOn ? 'ON' : 'OFF'}."); break; case "2": stdout.write("Enter temperature ($minTemp - $maxTemp): "); String? tempInput = stdin.readLineSync(); if (tempInput == null) break; int? newTemp = int.tryParse(tempInput); 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": securityArmed = !securityArmed; print("Security system is now ${securityArmed ? 'ARMED' : 'DISARMED'}."); break; case "4": print("\n--- SYSTEM STATUS ---"); // Lights status String lightStatus = lightsOn ? "ON" : "OFF"; // Security status (uppercase) String securityStatus = securityArmed ? "ARMED" : "DISARMED"; // FizzBuzz-like temperature message String tempMessage = ""; bool mult3 = thermostat % 3 == 0; bool mult5 = thermostat % 5 == 0; if (mult3 && mult5) { tempMessage = "Perfect Day"; } else if (mult3) { tempMessage = "Cool Day"; } else if (mult5) { tempMessage = "Warm Day"; } print("Lights: $lightStatus"); print("Thermostat: $thermostat°C ${tempMessage.isNotEmpty ? '($tempMessage)' : ''}"); print("Security System: ${securityStatus.toUpperCase()}"); break; default: print("Invalid choice. Please select a valid option."); } } }