Nested Conditionals FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A snack machine uses the segment below. Sensor values are temp = 4 and doorOpen = false. (a) State what is displayed and briefly justify with a trace of the outer and inner tests. (b) Change only doorOpen so that restock is displayed. Give that Boolean value. (c) Explain why the inner assignment to status is not reached when temp is 12 and doorOpen is true.

IF (temp < 5)
{
  IF (doorOpen)
  {
    status ← "restock"
  }
  ELSE
  {
    status ← "chilling"
  }
}
ELSE
{
  status ← "too warm"
}
DISPLAY (status)

Question 2 of 5

Ferry boarding nested structure. (a) Pair of tickets and standby that displays board. (b) Pair that displays wait. (c) Pair that displays denied and which test fails first.

IF (tickets > 0)
{
  IF (standby = false)
  {
    DISPLAY ("board")
  }
  ELSE
  {
    DISPLAY ("wait")
  }
}
ELSE
{
  DISPLAY ("denied")
}

Question 3 of 5

Garden sensor. moisture is 30 and shade is true. (a) Trace and state the final message. (b) Designer wants water soon whenever moisture < 40, regardless of shade. Can nesting moisture only inside shade achieve that? (c) Write corrected AP CSP pseudocode that displays water soon when moisture < 40 and ok otherwise.

IF (shade)
{
  IF (moisture < 40)
  {
    DISPLAY ("water soon")
  }
  ELSE
  {
    DISPLAY ("ok")
  }
}
ELSE
{
  DISPLAY ("full sun")
}

Question 4 of 5

Robot vacuum. battery is 18 and dockVisible is true. (a) What is displayed? Show each IF test result in order. (b) One battery value that makes the inner IF unreachable; what is displayed if dockVisible is true? (c) What must be true for dock now to appear?

IF (battery < 20)
{
  IF (dockVisible)
  {
    DISPLAY ("dock now")
  }
  ELSE
  {
    DISPLAY ("search dock")
  }
}
ELSE
{
  DISPLAY ("continue")
}

Question 5 of 5

Gated path program: IF (badgeOk) { IF (gateClear) { DISPLAY ("enter") } ELSE { DISPLAY ("wait") } } ELSE { DISPLAY ("reject") } (a) Fill outputs for each row. (b) Which row never evaluates gateClear? Justify. (c) Change row 2 inputs so wait becomes enter.

Row badgeOk gateClear Output
1 true true
2 true false
3 false true