completed functions

These are the completed functions from the Programming Assignment 2.