Added code for problem 1.2 and 1.4