Programming Assignment 2 version 3

Updated with comments describing what is happening in each step.