• Post Reply Bookmark Topic Watch Topic
  • New Topic

how do I do this  RSS feed

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a Math Utility that takes a Collection of any number (Integer) and
returns the average of that collection.
 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calculate the sum over the elements and then divide by the count.
Keep in mind though what to do with null values - you'll probably want to exclude them completely, and therefore you'll have to calculate the count as well - at the same time as the sum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!