Answer:
Code is in the attached screenshot.
Step-by-step explanation:
Assumed it was written in Java based on your other question asked.
9.4m questions
12.2m answers