import 'dart:io'; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; const int minTemp = 15; const int maxTemp = 30; print('Welcome to the Smart Home System!'); while (true) { print('\nPlease choose an action:'); print('1. Toggle lights'); print('2. Set thermostat temperature'); print('3. Arm/disarm security system'); print('4. View system status'); print('5. Exit'); String? input = stdin.readLineSync(); int? choice = int.tryParse(input ?? ''); switch (choice) { case 1: lightsOn = !lightsOn; print('Lights are now ${lightsOn ? 'ON' : 'OFF'}.'); break; case 2: print('Set thermostat temperature ($minTemp°C – $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 a value between $minTemp and $maxTemp.'); } break; case 3: securityArmed = !securityArmed; print('Security system is now ${securityArmed ? 'ARMED' : 'DISARMED'}.'); break; case 4: String tempMessage = thermostat.toString(); 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('\nSystem Status:'); print('- Lights: ${lightsOn ? 'ON' : 'OFF'}'); print('- Thermostat: $tempMessage°C'); print('- Security System: ${securityArmed ? 'ARMED' : 'DISARMED'}'); break; case 5: print('Exiting the system. Goodbye!'); return; default: print('Invalid choice. Please try again.'); } } }