Completed the functions
Solution to Programming Assignment 2