Created the functions for programming assignment 2