solution for ch6 problem 4