Solved exercises 30-37 from chapter 6