Program 15.16 from chapter 15