diff --git a/src/MMMCalc.java b/src/MMMCalc.java index a4d5128..3d9f040 100644 --- a/src/MMMCalc.java +++ b/src/MMMCalc.java @@ -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);