Program 15.04 from chapter 15