Answer:
Following is given the code with all necessary description given as comments in it. I hope it will help you!
Step-by-step explanation:
5.7m questions
7.4m answers