package com.levelup.java.array;

import static org.junit.Assert.assertEquals;

import org.apache.commons.math3.stat.StatUtils;
import org.junit.Test;

/**
 * This java example will demonstrate summing values in array.
 * 
 * @author Justin Musgrove
 * @see <a href='http://www.leveluplunch.com/java/'></a>
 * 
 */
public class SumValuesInArray {

	double[] numbers = {1, 24, 45, 62, 85, 8, 91, 3, 5, 56, 9};
	
	@Test
	public void sum_values_in_array_with_java () {
	
		double total = 0;
		for (double element : numbers) {
			total += element;
		}
		
		assertEquals(389, total, 0);
	}

	//TODO
//	@Test
//	@Ignore
//	public void sum_values_in_array_with_java_8 () {
//		int total = IntStream.of(numbers).sum();
//		assertEquals(389, total);
//	}

	@Test
	public void sum_values_in_array_with_apache_commons () {
		
		double total = StatUtils.sum(numbers);
		assertEquals(389, total, 0);
		
	}
	
}

@@ -296,10 +296,58 @@
 ava/
-'%3E
+examples/sum-values-in-array/'%3ESum values in array
 %3C/a%3E
@@ -588,19 +588,16 @@
 nt;%0A%09%09%7D%0A
-%09%09%0A
 %09%09assert
@@ -924,18 +924,15 @@
 al, 0);%0A
-%09%09%0A
 %09%7D%0A%09%0A%7D%0A

add link and formatting