solved exercises 7 in chapter6