import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int temperature = 20; bool securityArmed = false; while (true) { print('\n--- Smart Home Automation ---'); print('1. Toggle Lights'); print('2. Set Thermostat'); print('3. Arm/Disarm Security'); print('4. View System Status'); print('5. Exit'); stdout.write('Choose an option: '); String? choice = stdin.readLineSync(); if (choice == '5') { print('Exiting Smart Home... Goodbye!'); break; } else if (choice == '1') { lightsOn = !lightsOn; print('Lights turned ${lightsOn ? 'ON' : 'OFF'}.'); } else if (choice == '2') { stdout.write('Enter temperature ($minTemp–$maxTemp): '); int? temp = int.tryParse(stdin.readLineSync()!); if (temp != null && temp >= minTemp && temp <= maxTemp) { temperature = temp; print('Temperature set to $temperature°C.'); } else { print('Invalid temperature. Try again.'); } } else if (choice == '3') { securityArmed = !securityArmed; print('Security system ${securityArmed ? 'ARMED' : 'DISARMED'}.'); } else if (choice == '4') { String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; String tempMessage = ''; if (temperature % 3 == 0 && temperature % 5 == 0) { tempMessage = 'Perfect Day'; } else if (temperature % 3 == 0) { tempMessage = 'Cool Day'; } else if (temperature % 5 == 0) { tempMessage = 'Warm Day'; } print('\n--- System Status ---'); print('Lights: $lightsStatus'); print('Thermostat: $temperature°C ${tempMessage.isNotEmpty ? "($tempMessage)" : ""}'); print('Security: $securityStatus'); } else { print('Invalid choice, try again.'); } } }