solution to progAssignment2