import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; bool running = true; while (running) { print('Choose an option:'); print('1. Control Lights'); print('2. Adjust Thermostat'); print('3. Control Security System'); print('4. View System Status'); print('5. Exit'); stdout.write('Enter your choice (1-5): '); String? choice = stdin.readLineSync(); switch (choice) { case '1': stdout.write('Turn lights ON or OFF? '); String? lightInput = stdin.readLineSync()?.toLowerCase(); if (lightInput == 'on') { lightsOn = true; print('Lights turned ON.'); } else if (lightInput == 'off') { lightsOn = false; print('Lights turned OFF.'); } else { print('Invalid input. Please enter ON or OFF.'); } break; case '2': stdout.write('Set thermostat temperature ($minTemp-$maxTemp °C): '); String? tempInput = stdin.readLineSync(); int? temp = int.tryParse(tempInput ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to $thermostat°C.'); } else { print('Invalid temperature. Please enter between $minTemp and $maxTemp.'); } break; case '3': stdout.write('Arm or Disarm security system? '); String? secInput = stdin.readLineSync()?.toLowerCase(); if (secInput == 'arm') { securityArmed = true; print('Security system ARMED.'); } else if (secInput == 'disarm') { securityArmed = false; print('Security system DISARMED.'); } else { print('Invalid input. Please enter ARM or DISARM.'); } break; case '4': print('\n=== Smart Home Status ==='); print('Lights: ${lightsOn ? 'ON' : 'OFF'}'); 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('Thermostat: $thermostat°C ${tempMessage.isNotEmpty ? '($tempMessage)' : ''}'); print('Security System: ${securityArmed ? 'ARMED' : 'DISARMED'}\n'); break; case '5': running = false; print('Exiting Smart Home Automation System. Goodbye!'); break; default: print('Invalid choice. Please enter a number from 1 to 5.'); } print(''); } }