import 'dart:io'; void main() { // System State Variables bool lightsOn = false; int thermostatTemp = 20; // Default temp bool isArmed = false; bool running = true; print('Welcome to the Smart Home System!'); 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('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('Set thermostat temperature (15°C - 30°C): '); String? tempInput = stdin.readLineSync(); int? newTemp = int.tryParse(tempInput ?? ''); if (newTemp != null && newTemp >= 15 && newTemp <= 30) { thermostatTemp = newTemp; print('Thermostat set to $thermostatTemp°C.'); } else { print('Invalid temperature. Please enter a value between 15 and 30.'); } break; case '3': isArmed = !isArmed; print('Security System ${isArmed ? "ARMED" : "DISARMED"}.'); break; case '4': String tempContext = (thermostatTemp > 24) ? "Warm Day" : "Comfortable"; print('\nSystem Status:'); print('- Lights: ${lightsOn ? "ON" : "OFF"}'); print('- Thermostat: $thermostatTemp°C - $tempContext'); print('- Security System: ${isArmed ? "ARMED" : "DISARMED"}'); break; case '5': print('Exiting the system. Goodbye!'); running = false; break; default: print('Invalid choice, please try again.'); } } }