Solution Programming assignment 2