Fixed median calculation for even array length. Verbose needs fix.

This commit is contained in:
Deathsbreed 2014-04-10 17:24:08 -05:00
parent 14ce9cdc3c
commit 62d4d703a8

View File

@ -130,8 +130,15 @@ public class MMMCalc {
private static void calcMedian() {
int midVar = numArray.length / 2;
boolean even;
median = numArray[midVar];
if(numArray.length % 2 == 0) {
median = (numArray[midVar] + numArray[midVar-1]) / 2;
even = true;
} else {
median = numArray[midVar];
even = false;
}
System.out.println("Median: " + median);