import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; 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('Enter your choice: '); String? input = stdin.readLineSync(); int choice = int.tryParse(input ?? '') ?? 0; if (choice == 1) { // Toggle lights lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.'); } else if (choice == 2) { // Set thermostat stdout.write('Set thermostat temperature ($minTemp°C - $maxTemp°C): '); String? tempInput = stdin.readLineSync(); int? newTemp = int.tryParse(tempInput ?? ''); if (newTemp == null || newTemp < minTemp || newTemp > maxTemp) { print('Invalid temperature! Please enter a value between $minTemp and $maxTemp.'); } else { thermostat = newTemp; print('Thermostat set to $thermostat°C.'); } } else if (choice == 3) { // Arm/disarm security system securityArmed = !securityArmed; print('Security system is now ${securityArmed ? "ARMED" : "DISARMED"}.'); } else if (choice == 4) { // View system status String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; // FizzBuzz-like temperature label String tempLabel; if (thermostat % 3 == 0 && thermostat % 5 == 0) { tempLabel = 'Perfect Day'; } else if (thermostat % 3 == 0) { tempLabel = 'Cool Day'; } else if (thermostat % 5 == 0) { tempLabel = 'Warm Day'; } else { tempLabel = ''; } print('\nSystem Status:'); print('- Lights: $lightsStatus'); print('- Thermostat: $thermostat°C${tempLabel.isNotEmpty ? " - $tempLabel" : ""}'); print('- Security System: $securityStatus'); } else if (choice == 5) { print('Exiting the system. Goodbye!'); break; } else { print('Invalid choice. Please enter a number between 1 and 5.'); } } }