Complete program for the assignment