import 'dart:io'; void main() { // --- Constants ---// const int minTemp = 15; const int maxTemp = 30; // --- Initial values ---// bool lightsOn = false; int thermostatTemp = 20; bool securityArmed = false; print('Welcome to the Smart Home System!'); print('Please choose an option:'); print('1. Toggle lights'); print('2. Set thermostat temperature between $minTemp°C and $maxTemp°C'); print('3. Arm/disarm security system'); print('4. View system status'); print('5. Exit'); while (true) { int deviceCommands = int.parse(stdin.readLineSync()!); if (deviceCommands < 1 || deviceCommands > 5) { print('Invalid choice. Please enter a number between 1 and 5.'); continue; } switch (deviceCommands) { case 1: lightsOn = !lightsOn; print('- Lights: ${lightsOn ? 'ON' : 'OFF'}.'); break; case 2: while (true) { print('Enter desired temperature ($minTemp°C - $maxTemp°C):'); int input = int.parse(stdin.readLineSync()!); if (input < minTemp || input > maxTemp) { print( 'Invalid temperature. Please enter a value between $minTemp°C and $maxTemp°C.', ); continue; } thermostatTemp = input; print('Thermostat set to $thermostatTemp°C.'); break; } break; case 3: securityArmed = !securityArmed; print('- Security System: ${securityArmed ? 'ARMED' : 'DISARMED'}.'); break; case 4: print('System Status:'); print('Lights: ${lightsOn ? 'ON' : 'OFF'}.'); if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { print('$thermostatTemp - Perfect Day'); } else if (thermostatTemp % 3 == 0) { print('$thermostatTemp - Cool Day'); } else if (thermostatTemp % 5 == 0) { print('$thermostatTemp - Warm Day'); } print('Security System: ${securityArmed ? 'ARMED' : 'DISARMED'}.'); break; case 5: print('Exiting Smart Home System. Goodbye!'); break; } } }