import 'dart:io'; /// Smart Home Automation constants const int minTemp = 15; const int maxTemp = 30; void main() { // Smart Home Device Initial Status bool lightsOn = false; int thermostat = 20; bool securityArmed = false; while (true) { print('\n--- Smart Home Menu ---'); print('1. Toggle Lights'); print('2. Set Thermostat'); print('3. Arm/Disarm Security System'); print('4. View System Status'); print('5. Exit'); stdout.write('Enter your choice: '); String? shChoice = stdin.readLineSync(); switch (shChoice) { case '1': lightsOn = !lightsOn; print('Lights turned ${lightsOn ? "ON" : "OFF"}'); break; case '2': stdout.write('Enter temperature ($minTemp-$maxTemp °C): '); int? temp = int.tryParse(stdin.readLineSync() ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to $thermostat°C'); } else { print('Invalid temperature. Try again.'); } break; case '3': securityArmed = !securityArmed; print('Security system is now ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': String lightsStatus = lightsOn ? "ON" : "OFF"; String securityStatus = securityArmed ? "ARMED" : "DISARMED"; String tempMessage = ''; if (thermostat % 3 == 0 && thermostat % 5 == 0) { tempMessage = 'Perfect Day'; } else if (thermostat % 3 == 0) { tempMessage = 'Cool Day'; } else if (thermostat % 5 == 0) { tempMessage = 'Warm Day'; } print('\n--- System Status ---'); print('Lights: $lightsStatus'); print('Thermostat: $thermostat°C ${tempMessage.isNotEmpty ? "- $tempMessage" : ""}'); print('Security System: $securityStatus'); break; case '5': print('Exiting Smart Home Automation...'); return; default: print('Invalid choice. Try again.'); } } }