// Noor Bandar ALabsi_242000818_question1. // Smart Home Automation System // – Question 1 import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; bool securityArmed = false; print('=============================='); print('Welcome to Smart Home System'); print('=============================='); bool running = true; while (running) { print(''); print('Please choose an option:'); print('1. Turn lights ON/OFF'); print('2. Set thermostat temperature'); print('3. Arm/Disarm security system'); print('4. View system status'); print('5. Exit'); stdout.write('Enter your choice (1-5): '); String? input = stdin.readLineSync(); if (input == null) continue; input = input.trim(); int? choice = int.tryParse(input); if (choice == null || choice < 1 || choice > 5) { print('Invalid choice! Please enter a number between 1 and 5.'); continue; } switch (choice) { case 1: lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.'); break; case 2: stdout.write('Enter new temperature ($minTemp-$maxTemp): '); String? tempInput = stdin.readLineSync(); int? newTemp = int.tryParse(tempInput ?? ''); if (newTemp == null || newTemp < minTemp || newTemp > maxTemp) { print('Invalid temperature! Please enter between $minTemp and $maxTemp.'); } else { thermostat = newTemp; print('Thermostat set to $thermostat°C.'); } break; case 3: securityArmed = !securityArmed; print('Security system is now ${securityArmed ? "ARMED" : "DISARMED"}.'); break; case 4: print(''); print('========= SYSTEM STATUS ========='); print('Lights: ${lightsOn ? "ON" : "OFF"}'); print('Thermostat: $thermostat°C'); print('Security System: ${securityArmed ? "ARMED" : "DISARMED"}'); if (thermostat % 3 == 0 && thermostat % 5 == 0) { print('Perfect Day - $thermostat°C'); } else if (thermostat % 3 == 0) { print('Cool Day - $thermostat°C'); } else if (thermostat % 5 == 0) { print('Warm Day - $thermostat°C'); } print('================================='); break; case 5: running = false; print('\nExiting Smart Home System...'); print('Goodbye!'); break; } } }