Implementation of programming assignment 2