import 'dart:io'; void main() { bool lights = false; int temp = 20; bool security = 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'); stdout.write('\nEnter your choice: '); String? choice = stdin.readLineSync(); if (choice == '1') { lights = !lights; print('Lights are now ${lights ? 'ON' : 'OFF'}.'); } else if (choice == '2') { stdout.write('Set thermostat temperature ($minTemp°C – $maxTemp°C): '); int? newTemp = int.tryParse(stdin.readLineSync() ?? ''); if (newTemp != null && newTemp >= minTemp && newTemp <= maxTemp) { temp = newTemp; print('Thermostat set to $temp°C.'); } else { print('Invalid temperature!'); } } else if (choice == '3') { security = !security; print('Security system is now ${security ? 'ARMED' : 'DISARMED'}.'); } else if (choice == '4') { String status = ''; if (temp % 3 == 0 && temp % 5 == 0) { status = 'Perfect Day'; } else if (temp % 3 == 0) { status = 'Cool Day'; } else if (temp % 5 == 0) { status = 'Warm Day'; } print('\nSystem Status:'); print('- Lights: ${lights ? 'ON' : 'OFF'}'); print('- Thermostat: $temp°C ${status.isNotEmpty ? '- $status' : ''}'); print('- Security System: ${security ? 'ARMED' : 'DISARMED'}'); } else if (choice == '5') { print('Exiting the system. Goodbye!'); break; } else { print('Invalid choice.'); } } }