Implementation of Programming assignment 2