import 'dart:io'; void main() { String lights = 'OFF'; int thermostat = 20; String security = 'DISARMED'; const int minTemp = 15; const int maxTemp = 30; print('Welcome to the Smart Home System!'); bool isRunning = true; while (isRunning) { 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'); stdout.write('Enter your choice: '); String? choice = stdin.readLineSync(); switch (choice) { case '1': lights = (lights == 'OFF') ? 'ON' : 'OFF'; print('Lights are now $lights.'); break; case '2': stdout.write('Set thermostat temperature ($minTemp°C - $maxTemp°C): '); int? newTemp = int.tryParse(stdin.readLineSync() ?? ''); if (newTemp == null) { print('Invalid input. Please enter a number.'); } else if (newTemp < minTemp || newTemp > maxTemp) { print('Temperature must be between $minTemp and $maxTemp.'); } else { thermostat = newTemp; print('Thermostat set to $thermostat°C.'); } break; case '3': security = (security == 'DISARMED') ? 'ARMED' : 'DISARMED'; print('Security system is now $security.'); break; case '4': print('\nSystem Status:'); print('- Lights: $lights'); print('- Thermostat: $thermostat°C'); print('- Security System: $security'); if (thermostat % 3 == 0) print('Cool Day'); if (thermostat % 5 == 0) print('Warm Day'); if (thermostat % 2 == 0) print('Perfect Day'); break; case '5': isRunning = false; print('Exiting the system. Goodbye!'); break; default: print('Invalid choice. Please enter a number between 1 and 5.'); } } }