// Smart Home Automation System - Assignment 1 import 'dart:io'; void main() { const double minTemp = 15.0; const double maxTemp = 30.0; bool isLightsOn = false; double thermostatTemp = 20.0; bool isSecurityArmed = 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("Enter your choice: "); String? choice = stdin.readLineSync(); switch (choice) { case '1': isLightsOn = !isLightsOn; print("Lights are now ${isLightsOn ? 'ON' : 'OFF'}."); break; case '2': stdout.write("Set thermostat temperature ($minTemp - $maxTemp): "); double? inputTemp = double.tryParse(stdin.readLineSync() ?? ""); if (inputTemp != null && inputTemp >= minTemp && inputTemp <= maxTemp) { thermostatTemp = inputTemp; print("Thermostat set to $thermostatTemp°C."); } else { print("Invalid temperature! Please stay between $minTemp and $maxTemp."); } break; case '3': isSecurityArmed = !isSecurityArmed; print("Security system is now ${isSecurityArmed ? 'ARMED' : 'DISARMED'}."); break; case '4': String tempMsg = ""; if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) tempMsg = "Perfect Day"; else if (thermostatTemp % 3 == 0) tempMsg = "Cool Day"; else if (thermostatTemp % 5 == 0) tempMsg = "Warm Day"; print("\nSystem Status:"); print("Lights: ${isLightsOn ? 'ON' : 'OFF'}"); print("Thermostat: ${thermostatTemp}°C $tempMsg"); print("Security System: ${isSecurityArmed ? 'ARMED' : 'DISARMED'}"); break; case '5': print("Exiting the system. Goodbye!"); return; default: print("Invalid choice."); } } }