import 'dart:io'; void main() { // Const Variables for Temperature Range const int minTemp = 15; const int maxTemp = 30; // Device Status bool lightsOn = false; int thermostatTemp = 20; bool isArmed = false; print('Welcome to the Smart Home System!'); // User Interaction bool running = true; while (running) { 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: '); String? choice = stdin.readLineSync(); // Control Flow switch (choice) { case '1': lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.'); break; case '2': stdout.write('Set thermostat temperature ($minTemp°C – $maxTemp°C): '); String? tempInput = stdin.readLineSync(); int? newTemp = int.tryParse(tempInput ?? ''); // Input Validation & Logical Operators if (newTemp != null && newTemp >= minTemp && newTemp <= maxTemp) { thermostatTemp = newTemp; print('Thermostat set to $thermostatTemp°C.'); } else { print('Invalid input. Please enter a value between $minTemp and $maxTemp.'); } break; case '3': isArmed = !isArmed; // String Operation: Converting status to Uppercase String armStatus = isArmed ? 'armed' : 'disarmed'; print('Security System is now ${armStatus.toUpperCase()}.'); break; case '4': // Logic for temperature adjectives String tempCondition = ''; if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { tempCondition = '– Perfect Day'; } else if (thermostatTemp % 3 == 0) { tempCondition = '– Cool Day'; } else if (thermostatTemp % 5 == 0) { tempCondition = '– Warm Day'; } // status display print('System Status:'); print('- Lights: ${lightsOn ? "ON" : "OFF"}'); print('- Thermostat: $thermostatTemp°C $tempCondition'); print('- Security System: ${(isArmed ? "armed" : "disarmed").toUpperCase()}'); break; case '5': print('Exiting the system. Goodbye!'); running = false; break; default: print('Invalid choice. Please select 1-5.'); } } }