code for Assignment 6