Skip to content

Instantly share code, notes, and snippets.

@vontell
Created February 3, 2016 16:45
Show Gist options
  • Save vontell/29801e37009470c9648d to your computer and use it in GitHub Desktop.
Save vontell/29801e37009470c9648d to your computer and use it in GitHub Desktop.
public class CumulativeAverage {
public static void main(String[] args) {
int[] data = new int[] { 2, 4, 6 };
int total = 0;
int average = 0;
int n = 0;
for (int value : data) {
n += 1;
total += value;
average = total / n;
System.out.println("average: " + average);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment