Question 1 Report
A home security system uses three sensors:
DoorOpen - TRUE if any door is openWindowOpen - TRUE if any window is openAlarmSet - TRUE if the alarm is armedThe alarm sounds when: the alarm is set AND (a door is open OR a window is open).
(a) Write the Boolean expression for the alarm sounding. [1]
(b) Complete the truth table. [4]
| AlarmSet | DoorOpen | WindowOpen | Alarm sounds? |
|---|---|---|---|
| FALSE | FALSE | FALSE | |
| FALSE | TRUE | FALSE | |
| TRUE | FALSE | FALSE | |
| TRUE | TRUE | FALSE | |
| TRUE | FALSE | TRUE | |
| TRUE | TRUE | TRUE |
(c) Write pseudocode that implements this security system logic and outputs appropriate messages. [2]
(d) Write the Boolean expression for the alarm NOT sounding (using De Morgan's law). [1]
(a) The Boolean expression for the alarm sounding is:
AlarmSounds = AlarmSet AND (DoorOpen OR WindowOpen) [1]
The alarm requires the system to be armed AND at least one entry point to be open.
(b)
| AlarmSet | DoorOpen | WindowOpen | DoorOpen OR WindowOpen | Alarm sounds? |
|---|---|---|---|---|
| FALSE | FALSE | FALSE | FALSE | FALSE |
| FALSE | TRUE | FALSE | TRUE | FALSE |
| TRUE | FALSE | FALSE | FALSE | FALSE |
| TRUE | TRUE | FALSE | TRUE | TRUE |
| TRUE | FALSE | TRUE | TRUE | TRUE |
| TRUE | TRUE | TRUE | TRUE | TRUE |
When AlarmSet is FALSE (rows 1-2), the AND makes the result FALSE regardless of door/window state. [1] When AlarmSet is TRUE but both sensors are FALSE (row 3), the OR evaluates to FALSE. [1] When AlarmSet is TRUE and at least one sensor is TRUE (rows 4-6), the alarm sounds. [1] [1]
(c)
IF AlarmSet AND (DoorOpen OR WindowOpen) THEN
OUTPUT "ALARM: Intruder detected!"
IF DoorOpen THEN
OUTPUT "Door breach detected"
ENDIF
IF WindowOpen THEN
OUTPUT "Window breach detected"
ENDIF
ELSE
OUTPUT "System OK"
ENDIFThe Boolean expression is the IF condition. [1] Nested IFs identify which sensor(s) triggered. [1]
(d) Applying De Morgan's law:
NOT AlarmSet OR (NOT DoorOpen AND NOT WindowOpen) [1]
NOT (A AND B) = (NOT A) OR (NOT B), and NOT (C OR D) = (NOT C) AND (NOT D).
Everything you need to excel in your exams