import 'dart:io'; void main() { // Const values (final/const requirement) const int minTemp = 15; const int maxTemp = 30; // Default device values bool lightsOn = false; // lightsOff by default int thermostat = 20; // 20°C by default bool securityArmed = false; // disarmed by default 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: '); final String choiceInput = stdin.readLineSync() ?? ''; final int? choice = int.tryParse(choiceInput); if (choice == null) { print('Invalid input. Please enter a number (1-5).'); continue; } // if/else requirement for user choices if (choice == 1) { // switch requirement for device commands switch ('lights') { case 'lights': lightsOn = !lightsOn; print('Lights are now ${lightsOn ? 'ON' : 'OFF'}.'); break; } } else if (choice == 2) { switch ('thermostat') { case 'thermostat': int? temp; while (true) { stdout.write('Set thermostat temperature ($minTemp°C - $maxTemp°C): '); final String tempInput = stdin.readLineSync() ?? ''; temp = int.tryParse(tempInput); // Logical & relational operators for validation if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostat = temp; print('Thermostat set to ${thermostat}°C.'); break; } else { print('Invalid temperature. Please enter a value between $minTemp and $maxTemp.'); } } break; } } else if (choice == 3) { switch ('security') { case 'security': // Toggle armed/disarmed securityArmed = !securityArmed; // String operations requirement (e.g., "armed" -> "ARMED") final String statusText = (securityArmed ? 'armed' : 'disarmed').toUpperCase(); print('Security System is now $statusText.'); break; } } else if (choice == 4) { // Display system status with string interpolation final String lightsStatus = lightsOn ? 'ON' : 'OFF'; final String securityStatus = (securityArmed ? 'armed' : 'disarmed').toUpperCase(); // FizzBuzz-like requirement for temperature status final bool multipleOf3 = thermostat % 3 == 0; final bool multipleOf5 = thermostat % 5 == 0; String tempLabel = ''; if (multipleOf3 && multipleOf5) { tempLabel = ' - Perfect Day'; } else if (multipleOf3) { tempLabel = ' - Cool Day'; } else if (multipleOf5) { tempLabel = ' - Warm Day'; } print('\nSystem Status:'); print('- Lights: $lightsStatus'); print('- Thermostat: ${thermostat}°C$tempLabel'); print('- Security System: $securityStatus'); } else if (choice == 5) { print('Exiting the system. Goodbye!'); break; } else { print('Invalid choice. Please enter a number from 1 to 5.'); } } }