Programming task 2

 

Extend the previous program in the following way: