See the entire program below: