Back to Challenge Set 6

Code Challenge: Study Hall Pass

Difficulty  

divider

The Brief

What they asked for
Study hall is only for kids who are actually caught up. Ask
if their permission slip is signed and how many assignments
they're missing, and tell them whether they can stay.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Two facts have to both be true before the answer is yes — that is a single &&, not a chain and not an override.
  • The slip is a yes/no answer, read as a string. The missing-assignment count is a number.
  • There is no third rule here and nothing beats anything else. If you find yourself reaching for || or !, re-read the brief — they are not needed.
  • Decide what happens on a partial pass — slip signed but assignments still missing, or the other way around — and make sure your one else covers all of them the same way.

Where to Start

Only one-star challenges have this section. If you already know how to begin, skip it — and when you move up to two stars, working out the order yourself is part of the job.

  1. Read the slip answer as a string and the missing-assignment count as an int.
  2. Write one if that joins both conditions with &&.
  3. Add a single else for every other case.
  4. Test all four combinations — both good, both bad, and each one bad alone — before you submit.

Sample Output

Sample Output
Permission slip signed (yes/no)? yes
Missing assignments? 0
Cleared for study hall.

Verified in a real run. Change either input alone — slip to “no”, or missing assignments to anything but 0 — and the answer has to flip.


Submit

Your requirements list and your program file, named cc-study-hall-pass.

Commence Challenge