Program 9.1 from chapter 9