QUESTION IMAGE
Question
2 mark for review an office building has two floors. a computer program is used to control an elevator that travels between the two floors. physical sensors are used to set the following boolean variables. variable description onfloor1 set to true if the elevator is stopped on floor 1; otherwise set to false onfloor2 set to true if the elevator is stopped on floor 2; otherwise set to false callto1 set to true if the elevator is called to floor 1; otherwise set to false callto2 set to true if the elevator is called to floor 2; otherwise set to false the elevator moves when the door is closed and the elevator is called to the floor that it is not currently on. which of the following boolean expressions can be used in a selection statement to cause the elevator to move? a (onfloor1 and callto2) and (onfloor2 and callto1) b (onfloor1 and callto2) or (onfloor2 and callto1) c (onfloor1 or callto2) and (onfloor2 or callto1)
Step1: Analyze the condition for elevator movement
The elevator moves when it is called to a floor it's not on. If it's on floor1 (\(onFloor1 = true\)), it should move when called to floor2 (\(callTo2 = true\)). If it's on floor2 (\(onFloor2 = true\)), it should move when called to floor1 (\(callTo1 = true\)).
Step2: Evaluate each option
- Option A: \((onFloor1\ AND\ callTo2)\ AND\ (onFloor2\ AND\ callTo1)\)
This would require the elevator to be on both floors at the same time, which is impossible. So this option is incorrect.
- Option B: \((onFloor1\ AND\ callTo2)\ OR\ (onFloor2\ AND\ callTo1)\)
If \(onFloor1 = true\) and \(callTo2 = true\) (elevator on floor1, called to floor2) OR \(onFloor2 = true\) and \(callTo1 = true\) (elevator on floor2, called to floor1), the elevator moves. This matches the required condition.
- Option C: \((onFloor1\ OR\ callTo2)\ AND\ (onFloor2\ OR\ callTo1)\)
For example, if \(onFloor1 = true\) and \(callTo1 = true\) (elevator on floor1, called to floor1), this expression would be \((true\ OR\ false)\ AND\ (false\ OR\ true)=true\ AND\ true = true\), but the elevator shouldn't move in this case. So this option is incorrect.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
B. \((onFloor1\ AND\ callTo2)\ OR\ (onFloor2\ AND\ callTo1)\)