Completed code for ProgrammingAssignment2