programming exercise for chap1