Completed and working program for HW3