import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostat = 20; bool securityArmed = false; while (true) { print('\n--- Smart Home Control ---'); print('1. Turn Lights On/Off'); 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(); if (choice == '5') { print('Exiting Smart Home System... Goodbye!'); break; } switch (choice) { case '1': lightsOn = !lightsOn; print('Lights turned ${lightsOn ? "ON" : "OFF"}'); break; case '2': stdout.write('Enter temperature ($minTemp - $maxTemp): '); int? temp = int.tryParse(stdin.readLineSync()!); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Temperature set to $thermostat°C'); } else { print('Invalid temperature! Try again.'); } break; case '3': securityArmed = !securityArmed; print('Security system ${securityArmed ? "ARMED" : "DISARMED"}'); break; case '4': String lightsStatus = lightsOn ? "ON" : "OFF"; String securityStatus = securityArmed ? "ARMED" : "DISARMED"; String tempMsg = ''; if (thermostat % 3 == 0 && thermostat % 5 == 0) tempMsg = 'Perfect Day'; else if (thermostat % 3 == 0) tempMsg = 'Cool Day'; else if (thermostat % 5 == 0) tempMsg = 'Warm Day'; print('\n--- System Status ---'); print('Lights: $lightsStatus'); print('Thermostat: $thermostat°C ${tempMsg.isNotEmpty ? "($tempMsg)" : ""}'); print('Security System: $securityStatus'); break; default: print('Invalid choice! Please try again.'); } } }