Added code for part three.
Final changes for part 3 of first programming assignment.