Program

The program is attached below.