The following impliments the function for assignment 2.