Correct answer for programming assignment2