solved exercises 8 in chapter6