Programs 10.1 and 10.2 from chapter 10