The getAvg function

The getAvg function is shown in its entirety in Listing 5.