import 'dart:io'; const int MIN_TEMP = 15; const int MAX_TEMP = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; print('=== Smart Home Automation ==='); while (true) { print('\nChoose an option:'); print('1) Toggle lights'); print('2) Change thermostat temperature (15-30)'); print('3) Arm/Disarm security system'); print('4) Show system status'); print('5) Exit'); stdout.write('> '); String? choice = stdin.readLineSync(); if (choice == '5') { print('Exiting...'); break; } if (choice == '1') { switch (lightsOn) { case true: lightsOn = false; print('Lights: OFF'); break; case false: lightsOn = true; print('Lights: ON'); break; } } else if (choice == '2') { stdout.write('Enter temperature ($MIN_TEMP-$MAX_TEMP): '); String? tempStr = stdin.readLineSync(); int? temp = int.tryParse(tempStr ?? ''); if (temp == null || temp < MIN_TEMP || temp > MAX_TEMP) { print('Invalid input. Try again.'); continue; } thermostat = temp; print('Thermostat set to ${thermostat}°C'); } else if (choice == '3') { if (!securityArmed) { securityArmed = true; print('Security system: ARMED'); } else { securityArmed = false; print('Security system: DISARMED'); } } else if (choice == '4') { String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; String tempStatus = ''; bool multipleOf3 = thermostat % 3 == 0; bool multipleOf5 = thermostat % 5 == 0; if (multipleOf3 && multipleOf5) { tempStatus = 'Perfect Day'; } else if (multipleOf3) { tempStatus = 'Cool Day'; } else if (multipleOf5) { tempStatus = 'Warm Day'; } print('\n--- System Status ---'); print('Lights: $lightsStatus'); print('Thermostat: ${thermostat}°C ($tempStatus)'); print('Security: $securityStatus'); print('---------------------'); } else { print('Invalid choice. Try again.'); } } }