import 'dart:io'; void main() { const int minTemp = 15; const int maxTemp = 30; bool lightsOn = false; int thermostatTemp = 20; bool securityArmed = false; print('Welcome to the Smart Home System!'); print('Please 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\n'); bool running = true; while (running) { stdout.write('Enter your choice: '); String? input = stdin.readLineSync(); if (input == null || input.isEmpty) { print('Invalid input.\n'); continue; } int? choice = int.tryParse(input); if (choice == null) { print('Invalid input.\n'); continue; } switch (choice) { case 1: if (lightsOn == true) { lightsOn = false; print('Lights are now OFF.\n'); } else { lightsOn = true; print('Lights are now ON.\n'); } break; case 2: print('Set thermostat temperature ($minTemp°C - $maxTemp°C): '); String? tempInput = stdin.readLineSync(); if (tempInput != null && tempInput.isNotEmpty) { int? temp = int.tryParse(tempInput); if (temp != null && temp >= minTemp && temp <= maxTemp) { thermostatTemp = temp; print('Thermostat set to $thermostatTemp°C.\n'); } else { print('Invalid temperature. Please enter a value between $minTemp°C and $maxTemp°C.\n'); } } else { print('Invalid input.\n'); } break; case 3: if (securityArmed == true) { securityArmed = false; print('Security system is now DISARMED.\n'); } else { securityArmed = true; print('Security system is now ARMED.\n'); } break; case 4: print('System Status:'); if (lightsOn == true) { print('- Lights: ON'); } else { print('- Lights: OFF'); } if (thermostatTemp % 3 == 0 && thermostatTemp % 5 == 0) { print('- Thermostat: $thermostatTemp°C - Perfect Day'); } else if (thermostatTemp % 3 == 0) { print('- Thermostat: $thermostatTemp°C - Cool Day'); } else if (thermostatTemp % 5 == 0) { print('- Thermostat: $thermostatTemp°C - Warm Day'); } else { print('- Thermostat: $thermostatTemp°C'); } if (securityArmed == true) { String status = 'armed'; print('- Security System: ${status.toUpperCase()}\n'); } else { String status = 'disarmed'; print('- Security System: ${status.toUpperCase()}\n'); } break; case 5: print('Exiting the system. Goodbye!'); running = false; break; default: print('Invalid choice.\n'); break; } } }