// Smart Home Automation CLI - Dart // Save this file as question1.txt import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; print('Welcome to Smart Home CLI'); while (true) { print('\nChoose an option:'); print('1. Control Lights'); print('2. Set Thermostat'); print('3. Control Security System'); print('4. View System Status'); print('5. Exit'); stdout.write('Enter choice (1-5): '); String? input = stdin.readLineSync(); if (input == null) continue; if (input == '5') { print('Exiting Smart Home CLI. Goodbye!'); break; } if (input != '1' && input != '2' && input != '3' && input != '4') { print('Invalid choice. Please enter a number between 1 and 5.'); continue; } switch (input) { case '1': stdout.write('Turn lights ON or OFF? (on/off): '); String? li = stdin.readLineSync(); if (li == null) break; li = li.trim().toLowerCase(); if (li == 'on') { lightsOn = true; print('Lights turned ON.'); } else if (li == 'off') { lightsOn = false; print('Lights turned OFF.'); } else { print('Invalid input for lights. Use "on" or "off".'); } break; case '2': while (true) { stdout.write('Enter thermostat temperature ($minTemp-$maxTemp °C): '); String? t = stdin.readLineSync(); if (t == null) break; int? value = int.tryParse(t.trim()); if (value == null) { print('Please enter a valid integer temperature.'); continue; } if (value < minTemp || value > maxTemp) { print('Temperature out of range. Please enter between $minTemp and $maxTemp.'); continue; } thermostat = value; print('Thermostat set to ${thermostat}°C.'); break; } break; case '3': stdout.write('Arm or Disarm security system? (arm/disarm): '); String? s = stdin.readLineSync(); if (s == null) break; s = s.trim().toLowerCase(); if (s == 'arm') { securityArmed = true; print('Security system ARMED.'); } else if (s == 'disarm') { securityArmed = false; print('Security system DISARMED.'); } else { print('Invalid input for security system. Use "arm" or "disarm".'); } break; case '4': String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'armed' : 'disarmed'; String securityDisplay = securityStatus.toUpperCase(); String tempNote = ''; bool multipleOf3 = (thermostat % 3 == 0); bool multipleOf5 = (thermostat % 5 == 0); if (multipleOf3 && multipleOf5) { tempNote = ' - Perfect Day'; } else if (multipleOf3) { tempNote = ' - Cool Day'; } else if (multipleOf5) { tempNote = ' - Warm Day'; } print('\n--- System Status ---'); print('Lights: ${lightsStatus}'); print('Thermostat: ${thermostat}°C${tempNote}'); print('Security System: ${securityDisplay}'); print('---------------------'); break; } } }