The brief program is shown below. The detailed program will be uploaded later.
image.png