logo

AQA A-Level Computer Science practice

An alarm should sound when a door is open and either the security code is invalid or a window is open.\n\na) Write a Boolean expression for the alarm condition using DoorOpen, CodeValid and WindowOpen.\nb) Evaluate the expression for each case below:\n\n1. DoorOpen = true, CodeValid = true, WindowOpen = true\n2. DoorOpen = true, CodeValid = false, WindowOpen = false\n3. DoorOpen = false, CodeValid = false, WindowOpen = true

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Abstraction and automation

Exam-style question

Try this first

An alarm should sound when a door is open and either the security code is invalid or a window is open.\n\na) Write a Boolean expression for the alarm condition using DoorOpen, CodeValid and WindowOpen.\nb) Evaluate the expression for each case below:\n\n1. DoorOpen = true, CodeValid = true, WindowOpen = true\n2. DoorOpen = true, CodeValid = false, WindowOpen = false\n3. DoorOpen = false, CodeValid = false, WindowOpen = true.

Answer and explanation

Concise answer

a) DoorOpen AND (NOT CodeValid OR WindowOpen).

Why this is correct

The door condition must be true, so DoorOpen is joined to the other condition with AND. The alarm-related alternatives are an invalid code or an open window, so they are joined with OR. In case 1, NOT CodeValid is false but WindowOpen is true, making the OR part true; the complete expression is true. In case 2, both DoorOpen and NOT CodeValid are true, so the result is true.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions