Please read this, which is on the contents page of
this forum:-
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
By providing a complete solution you are depriving the OP of the opportunity to learn from this experience; also if this is assessed work there is a risk OP will be accused of plagiarism and get a mark of 0.
Please don't get annoyed, but I have pulled rank and deleted the solution, except one part which regular readers will doubtless see in a few seconds will fail to “work”.