import 'dart:io'; // Constants const int minTemp = 15; const int maxTemp = 30; // Device Status bool lightsOn = false; int thermostatTemp = 20; bool securityArmed = false; // Main Method void main() { print("Welcome to the Smart Home System!"); while (true) { print("\nChoose an option:"); print("1. Toggle lights ON/OFF"); print("2. Set thermostat temperature"); print("3. Arm/Disarm security system"); print("4. Show system status"); print("5. Exit"); String? choice = stdin.readLineSync(); if (choice == '5') { print("Program terminated. Goodbye!"); break; } switch (choice) { case '1': toggleLights(); break; case '2': setThermostat(); break; case '3': toggleSecurity(); break; case '4': showStatus(); break; default: print("Please enter a valid option."); } } } // Toggle Lights void toggleLights() { lightsOn = !lightsOn; print("Lights have been ${lightsOn ? 'turned ON' : 'turned OFF'}."); } // Set Thermostat void setThermostat() { print("Enter temperature between $minTemp and $maxTemp:"); String? input = stdin.readLineSync(); int? temp = int.tryParse(input ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostatTemp = temp; print("Temperature set to $thermostatTemp°C."); } else { print("Invalid temperature. Please try again."); } } // Toggle Security System void toggleSecurity() { securityArmed = !securityArmed; print("Security system has been ${securityArmed ? 'armed' : 'disarmed'}."); } // Show System Status void showStatus() { String lightsStatus = lightsOn ? "ON" : "OFF"; String securityStatus = securityArmed ? "ARMED" : "DISARMED"; print("\n--- System Status ---"); print("Lights: $lightsStatus"); print("Temperature: $thermostatTemp°C"); // FizzBuzz-like logic if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { print("Perfect Day"); } else if (thermostatTemp % 3 == 0) { print("Cool Day"); } else if (thermostatTemp % 5 == 0) { print("Warm Day"); } print("Security System: ${securityStatus.toUpperCase()}"); }