Program 15.10 from chapter 15