Posted By

mscribellito on 03/24/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mscribellito


Accumulator


 / Published in: Java
 

  1. public class Accumulator {
  2.  
  3. private double total;
  4. private int n;
  5.  
  6. public void addDataValue(double val) {
  7. total += val;
  8. n++;
  9. }
  10.  
  11. public double mean() {
  12. return total / n;
  13. }
  14.  
  15. public void reset() {
  16. total = n = 0;
  17. }
  18.  
  19. }

Report this snippet  

You need to login to post a comment.