solve exercise 31.17