NumberToWordsConverter { public static String convert(int num) { if (Math.abs(num) > MAX) { throw new IllegalArgumentException(); } if (num < 0) { return "minus " + convert(-num); } if (num >= 100) { int hun = num / 100; return convert(hun) + " hundred" + (num % 100 > 0 ? " " + convert(num % 100) : ""); } if (num >= 20) { int ten = num / 10; return tens[ten] + (num % 10 > 0 ? " " +convert(num % 10) : ""); } return lowNums[num]; }  static String convert(int num);  }
@Test public void testConvert() { assertEquals(expected, NumberToWordsConverter.convert(input)); }
@Test(expected = IllegalArgumentException.class) public void testOutOfRange(){ NumberToWordsConverter.convert(NumberToWordsConverter.MAX + 1); }