Implemented the two functions to complete the programming assignment.