import 'dart:io'; void main() { const double minTemp = 15.0; const double maxTemp = 30.0; bool lightsOn = false; double thermostat = 20.0; bool securityArmed = false; print('Welcome to the Smart Home System!'); while (true) { print('\nChoose an option:'); print('1. Toggle 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(); switch (choice) { case '1': lightsOn = !lightsOn; print('Lights are now ${lightsOn ? 'ON' : 'OFF'}.'); break; case '2': stdout.write('Enter temperature (${minTemp.toInt()}-${maxTemp.toInt()}): '); String? tempInput = stdin.readLineSync(); double? temp = double.tryParse(tempInput ?? ''); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to $thermostat°C'); } else { print('Invalid temperature. Please enter a value between $minTemp and $maxTemp.'); } break; case '3': securityArmed = !securityArmed; print('Security system is now ${securityArmed ? 'ARMED' : 'DISARMED'}.'); break; case '4': String coolOrWarm; if (thermostat % 3 == 0 && thermostat % 5 == 0) { coolOrWarm = 'Perfect Day'; } else if (thermostat % 3 == 0) { coolOrWarm = 'Cool Day'; } else if (thermostat % 5 == 0) { coolOrWarm = 'Warm Day'; } else { coolOrWarm = ''; } print('\n--- System Status ---'); print('Lights: ${lightsOn ? 'ON' : 'OFF'}'); print('Thermostat: $thermostat°C ${coolOrWarm.isNotEmpty ? '- $coolOrWarm' : ''}'); print('Security: ${securityArmed ? 'ARMED' : 'DISARMED'}'); print('---------------------\n'); break; case '5': print('Exiting system. Goodbye!'); return; default: print('Invalid choice. Try again.'); } } }