Irregularities in Time

Audience: Beginning programming students

Objectives

  1. Students will know how to catch exceptional conditions
  2. Students will learn to assume things will go wrong even when this is not obvious

Exercise

You are writing a direct deposit program for the University. I am paid $100 per day. Your job is to write a program that will deposit $100 in my account every night at exactly 1:20AM, and email me confirmation that the deposit has been made.

To make the deposit, treat the file “/class/bankaccount/2314243” as my bank account. It contains an integer. Your program is to read in the integer, add $100 to it, and write the result back into the file. Don’t forget to mail me that you have done so, and the new balance, every time your program runs.

Discussion questions

  1. What happens when Daylight Savings Time begins and ends?
  2. How do you validate that the number in my bank account is reasonable?