chapter 4 exercises: calculate average of a vector of double