Completed program
Made modification to part a) of the problem