### Question:
BodyMassIndex { public Double calculate(Double weight, Double height) { Double result = null; if ((weight != null) && (height != null) && (weight > 0.0) && (height > 0.0)) { Double tmp = weight / (height * height); BigDecimal bd = new BigDecimal(tmp); MathContext mathContext = new MathContext(4); bd = bd.round(mathContext); result = bd.doubleValue(); } return result; }  Double calculate(Double weight, Double height);  }### Answer:
@Test public void test_valid_inputs() { final Double expectedResult = 26.23; Double result = instance.calculate(85.0, 1.8); assertEquals(expectedResult, result); }
@Test public void test_null_weight_input() { Double result = instance.calculate(null, 1.8); assertNull(result); }
@Test public void test_null_height_input() { Double result = instance.calculate(75.0, null); assertNull(result); }
@Test public void test_zero_height_input() { Double result = instance.calculate(75.0, 0.0); assertNull(result); }
@Test public void test_zero_weight_input() { Double result = instance.calculate(0.0, 1.8); assertNull(result); }
@Test public void test_zero_weight_input_forces_additional_checks() { Double result = instance.calculate(0.0, 1.8); if (result == null) { System.out.println("Incorrect input to BMI calculation"); } else { System.out.println("Your BMI is: " + result.doubleValue()); } }