solved exercises 3 and 4 in chapter6