I found no question from you here. What there is looks like a copy/paste of the homework, some code and again no question found or statement from you what issue you think there is with the code as it is.
Take a moment to either ask a question or write what you think is wrong with the code.