Completed code for the two functions as required by instructions for Programming Assignment 2