Program 15.11 from chapter 15