creating the solution for problem 2 part b.