DivideUsingSubtraction { public float divideRecursive(int dividend, int divider) { validateInput(divider); if (dividend == 0) { return 0f; } else if (dividend < divider) { return (float) dividend / (float) divider; } else { return 1f + divideRecursive(dividend - divider, divider); } }  float divideIterative(int dividend, int divider); float divideRecursive(int dividend, int divider);  }
@Test(expected = IllegalArgumentException.class) public void anyNumberDividedByZeroIsNotDefinedRecursive() { int dividend = 100; int divider = 0; divideUsingSubtraction.divideRecursive(dividend, divider); }
@Test public void fourDividedByTwoEqualsToTwoRecursive() { int dividend = 4; int divider = 2; float result = divideUsingSubtraction.divideRecursive(dividend, divider); assertEquals(2, result, DELTA); }
@Test public void fiveDividedByTwoEqualsToTwoPointFiveRecursive() { int dividend = 5; int divider = 2; float result = divideUsingSubtraction.divideRecursive(dividend, divider); assertEquals(2.5, result, DELTA); }
@Test public void sixtyDividedByTwelveEqualsToFiveRecursive() { int dividend = 60; int divider = 12; float result = divideUsingSubtraction.divideRecursive(dividend, divider); assertEquals(5, result, DELTA); }