my solution to Programming Assigment 2