implemented Programming Assignment #2