Based on the program below, answer the following questions: Q3.1…