// Smart Home Automation CLI - Question 1 // Author: Rania Mohammad Abdulkarim // ID: 251000739 // Simple, readable Dart console app implementing the specified features. import 'dart:io'; const int MIN_TEMP = 15; const int MAX_TEMP = 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) Toggle lights'); print('2) Set thermostat'); print('3) Arm/Disarm security system'); print('4) View system status'); print('5) Exit'); stdout.write('Enter choice (1-5): '); String? input = stdin.readLineSync(); if (input == null) continue; int? choice = int.tryParse(input); if (choice == null) { print('Invalid input. Please enter a number between 1 and 5.'); continue; } if (choice == 5) { print('Exiting Smart Home CLI. Goodbye!'); break; } else if (choice >= 1 && choice <= 4) { switch (choice) { case 1: lightsOn = !lightsOn; print('Lights turned ${lightsOn ? 'ON' : 'OFF'}.'); break; case 2: while (true) { stdout.write('Enter thermostat temperature ($MIN_TEMP-$MAX_TEMP): '); String? t = stdin.readLineSync(); int? temp = int.tryParse(t ?? ''); if (temp == null) { print('Please enter a valid integer.'); continue; } if (temp < MIN_TEMP || temp > MAX_TEMP) { print('Temperature out of range. Try again.'); continue; } else { thermostat = temp; print('Thermostat set to ${thermostat}°C.'); break; } } 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'; securityStatus = securityStatus.toUpperCase(); print('\n--- System Status ---'); print('Lights: $lightsStatus'); print('Thermostat: ${thermostat}°C'); print('Security System: $securityStatus'); bool mult3 = (thermostat % 3 == 0); bool mult5 = (thermostat % 5 == 0); if (mult3 && mult5) { print('Perfect Day (${thermostat}°C)'); } else if (mult3) { print('Cool Day (${thermostat}°C)'); } else if (mult5) { print('Warm Day (${thermostat}°C)'); } print('---------------------\n'); break; } } else { print('Choice out of range. Please pick 1-5.'); } } }