Added comments and function code to complete the programming assignment.