Learn AP Comp Sci

☰

Problem of the Day

Tuesday, October 20, 2026


Problem:

The boolean variable isWorkDay is true on days I have to work, and the boolean variable isDirty is true when my favorite shirt needs to be washed. I'll wear my favorite shirt on a work day, but only if it's clean. Otherwise, on non-work days, I'll wear it even if it's dirty. Which statement below will evaluate as true when I can wear my favorite shirt?

  1. (!isWorkDay && !isDirty) || isWorkDay
  2. (!isWorkDay || !isDirty) && isWorkDay
  3. !isWorkDay || (isWorkDay && !isDirty)
  4. !isWorkDay || (isWorkDay || !isDirty)

Show solution:

The correct answer is c. That statement evaluates as true for any non-work day, or if it is a work day and the shirt is not dirty. None of the other expressions work correctly under all possible conditions.