my code for prog assignment 2