answer for ProgrammingAssignment2