Program 9.2 from chapter 9