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