my solution to programming assignment 2