import 'dart:io'; void main() { // Final/Const variables const int minTemp = 15; const int maxTemp = 30; // Initial device states bool lightsOn = false; int thermostat = 20; String securitySystem = "disarmed"; print("Welcome to the Smart Home System!"); bool isRunning = true; while (isRunning) { 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("\nEnter your choice: "); String? choice = stdin.readLineSync(); switch (choice) { case '1': // Toggle lights lightsOn = !lightsOn; print("Lights are now ${lightsOn ? "ON" : "OFF"}."); break; case '2': // Set thermostat temperature stdout.write( "Set thermostat temperature ($minTemp°C - $maxTemp°C): "); String? inputTemp = stdin.readLineSync(); if (inputTemp != null) { int? newTemp = int.tryParse(inputTemp); if (newTemp == null) { print("Invalid input! Please enter a valid number."); } else if (newTemp < minTemp || newTemp > maxTemp) { print( "Temperature must be between $minTemp°C and $maxTemp°C."); } else { thermostat = newTemp; print("Thermostat set to $thermostat°C."); } } break; case '3': // Arm/disarm security system if (securitySystem == "disarmed") { securitySystem = "armed"; } else { securitySystem = "disarmed"; } print( "Security system is now ${securitySystem.toUpperCase()}."); break; case '4': // View system status print("\nSystem Status:"); // FizzBuzz-like logic for temperature String dayMessage = ""; if (thermostat % 3 == 0 && thermostat % 5 == 0) { dayMessage = "Perfect Day"; } else if (thermostat % 3 == 0) { dayMessage = "Cool Day"; } else if (thermostat % 5 == 0) { dayMessage = "Warm Day"; } print("- Lights: ${lightsOn ? "ON" : "OFF"}"); print("- Thermostat: $thermostat°C" "${dayMessage.isNotEmpty ? " - $dayMessage" : ""}"); print("- Security System: ${securitySystem.toUpperCase()}"); break; case '5': print("Exiting the system. Goodbye!"); isRunning = false; break; default: print("Invalid choice. Please try again."); } } }