chapter 4 programming example