my solution to programming assignment2