Back to Challenge Set 4

Code Challenge: Curfew Check

Difficulty  

divider

The Brief

What they asked for
My kid's curfew is 11:00 PM, and the argument every weekend
is what happens if he walks in at exactly 11:00 -- he says on
the dot counts as on time, I say a curfew means before. Type
in how many minutes late he is (negative if he's early) and
settle it before we argue about it again.

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


Notes

  • Two outcomes, so this is one if with one else. It does not need a chain.
  • The boundary is not a detail here — it is the whole brief. They told you exactly 11:00 is what they argue about every weekend. Your requirements list has to say what your program does at zero minutes late and why.
  • There is no wrong choice, only an undocumented one. A program that is defensible either way and says which way it went is complete. A program that got there by accident is not.
  • Minutes are whole numbers. Think about what your program should do with a large negative number (arriving hours early), and say so in your list even if you decide it needs no special handling.

Sample Output

Sample Output
Minutes late: -5
Home on time.

A student who is 20 minutes late should get grounded. Test -1, 0, and 1, and make sure the answer at 0 is the one your requirements list promised.


Submit

Your requirements list and your program file, named cc-curfew-check.

Commence Challenge