// smart_home.dart import 'dart:io'; const int minTemp = 15; const int maxTemp = 30; void main() { bool lightsOn = false; int thermostat = 20; bool securityArmed = false; bool running = true; while (running) { print('\nWelcome 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'); stdout.write('\nEnter your choice: '); String? choice = stdin.readLineSync(); if (choice == null) continue; switch (choice) { case '1': // toggle lights lightsOn = !lightsOn; print('Lights are now ${lightsOn ? "ON" : "OFF"}.'); break; case '2': // set thermostat while (true) { stdout.write('Set thermostat temperature ($minTemp°C - $maxTemp°C): '); String? input = stdin.readLineSync(); if (input == null) continue; int? t = int.tryParse(input); if (t == null || t < minTemp || t > maxTemp) { print('Invalid temperature. Please enter between $minTemp and $maxTemp.'); continue; } thermostat = t; print('Thermostat set to ${thermostat}°C.'); break; } break; case '3': // arm/disarm security stdout.write('Enter "arm" to ARM or "disarm" to DISARM: '); String? cmd = stdin.readLineSync(); if (cmd != null) { if (cmd.toLowerCase() == 'arm') { securityArmed = true; print('Security system is now ARMED.'); } else if (cmd.toLowerCase() == 'disarm') { securityArmed = false; print('Security system is now DISARMED.'); } else { print('Invalid command. Use "arm" or "disarm".'); } } break; case '4': // view status String lightsStatus = lightsOn ? 'ON' : 'OFF'; String securityStatus = securityArmed ? 'ARMED' : 'DISARMED'; // FizzBuzz-like for temperature String dayRemark = ''; bool mult3 = (thermostat % 3 == 0); bool mult5 = (thermostat % 5 == 0); if (mult3 && mult5) dayRemark = ' — Perfect Day'; else if (mult3) dayRemark = ' — Cool Day'; else if (mult5) dayRemark = ' — Warm Day'; print('\nSystem Status:'); print('- Lights: ${lightsStatus.toUpperCase()}'); print('- Thermostat: ${thermostat}°C${dayRemark}'); print('- Security System: ${securityStatus.toUpperCase()}'); break; case '5': print('Exiting the system. Goodbye!'); running = false; break; default: print('Invalid choice. Please choose 1-5.'); } } }