### Question:
HardyWeinbergCalculation { public static double hwCalculate(int obsAA, int obsAB, int obsBB) { int diplotypes = obsAA + obsAB + obsBB; int rare = (obsAA * 2) + obsAB; int hets = obsAB; if (rare > diplotypes) { rare = (2 * diplotypes) - rare; } if (hets > rare) { return -1; } double[] tailProbs = new double[rare + 1]; for (int z = 0; z < tailProbs.length; z++) { tailProbs[z] = 0; } int mid = (int) (((long) rare * ((2 * diplotypes) - rare)) / (2 * diplotypes)); if (((rare & 1) ^ (mid & 1)) != 0) { mid++; } int het = mid; int hom_r = (rare - mid) / 2; int hom_c = diplotypes - het - hom_r; tailProbs[mid] = 1.0; double sum = tailProbs[mid]; for (het = mid; het > 1; het -= 2) { tailProbs[het - 2] = (tailProbs[het] * het * (het - 1.0)) / (4.0 * (hom_r + 1.0) * (hom_c + 1.0)); sum += tailProbs[het - 2]; hom_r++; hom_c++; } het = mid; hom_r = (rare - mid) / 2; hom_c = diplotypes - het - hom_r; for (het = mid; het <= (rare - 2); het += 2) { tailProbs[het + 2] = (tailProbs[het] * 4.0 * hom_r * hom_c) / ((het + 2.0) * (het + 1.0)); sum += tailProbs[het + 2]; hom_r--; hom_c--; } for (int z = 0; z < tailProbs.length; z++) { tailProbs[z] /= sum; } double top = tailProbs[hets]; for (int i = hets + 1; i <= rare; i++) { top += tailProbs[i]; } double otherSide = tailProbs[hets]; for (int i = hets - 1; i >= 0; i--) { otherSide += tailProbs[i]; } if ((top > 0.5) && (otherSide > 0.5)) { return 1.0; } if (top < otherSide) { return top * 2; } return otherSide * 2; } private  HardyWeinbergCalculation(); static double hwCalculate(int obsAA, int obsAB, int obsBB);  }### Answer:
@Test(expected = ArithmeticException.class) public void hwCalculateFail() throws Exception { HardyWeinbergCalculation.hwCalculate(0, 0, 0); }