Program 16.1 from chapter 16