Percentage { public static String format( double hits , double total ) throws NoPercentException { double perc = perc( hits, total ); return String.format( "%3.2f%%", perc ); }  static String format( double hits , double total ); static double perc( double hits, double total );  }
@Test public void testFormat() throws Exception { assertEquals( "0.00%", Percentage.format( 0, 100 ) ); assertEquals( "50.00%", Percentage.format( 50, 100 ) ); assertEquals( "100.00%", Percentage.format( 100, 100 ) ); }