Added code for exercise5 and 7 hw3