import 'dart:io'; void main() { const int Max_Temp = 30; const int Min_Temp = 15; bool lights_on = false; bool security_armed = false; int thermostat = 20; print("Welcome to the smart home system!\n"); bool task = true; while (task) { print("Please choose an action:"); print("1. Toggle lights"); print("2. Set thermostat temperure"); print("3. Arm/Disarm security systwm"); print("4. View system status"); print("5. Exit\n"); print("Enter your choice:"); String? input = stdin.readLineSync(); int? choice = int.tryParse(input ?? ''); if (choice == null) { print("invalid input .\nplease rnter a number 1 - 5 .\n"); continue; } switch (choice) { case 1: //ok lights_on = !lights_on; print("Lights are now ${lights_on ? '(ON)' : '(OFF)'}.\n"); //ok break; case 2: //ok print("Set thermostat temperture ($Min_Temp c - $Max_Temp c):"); String? temp_input = stdin.readLineSync(); int? new_temp = int.tryParse(temp_input ?? ''); if (new_temp == null || new_temp < Min_Temp || new_temp > Max_Temp) { print("invalid !!. please enter between $Min_Temp and $Max_Temp.\n"); } else { thermostat = new_temp; } print("Thermostat set to $thermostat c .\n"); break; case 3: //ok security_armed = !security_armed; print( "Security System: ${security_armed ? '(ARMED)' : '(DISARMED)'}.\n", ); break; case 4: print("System status:"); print("- Lights:${lights_on ? '(ON)' : '(OFF)'}"); String weather = ""; if (thermostat % 3 == 0 && thermostat % 5 == 0) { weather = "perfect day"; } else if (thermostat % 3 == 0) { weather = "cool day"; } else if (thermostat % 5 == 0) { weather = "warm day"; } print("- thermostat: $thermostat c $weather"); print( "- Security System: ${security_armed ? '(ARMED)' : '(DISARMED)'}.\n", ); break; case 5: //ok print("Eixting the system . Goodbye!"); task = false; break; default: //ok print("Please enter a valid option (1-5)."); } } }