### Question:
ButterworthIIRDesigner extends AbstractIIRDesigner { @Override protected int calculateFilterOrder(FilterType type, double[] wp, double[] ws, double gpass, double gstop, boolean analog) throws BadFilterParametersException { double[] passb; double[] stopb; if (!analog) { passb = prewarpFrequencies(wp); stopb = prewarpFrequencies(ws); } else { passb = wp.clone(); stopb = ws.clone(); } double frequencyRatio = calculateFrequencyRatio(type, passb, stopb, gpass, gstop); double GSTOP = Math.pow(10.0, 0.1 * Math.abs(gstop)); double GPASS = Math.pow(10.0, 0.1 * Math.abs(gpass)); int filterOrder = (int)(Math.ceil(Math.log10((GSTOP - 1.0) / (GPASS - 1.0)) / (2 * Math.log10(frequencyRatio)))); if (filterOrder == 0) throw new BadFilterParametersException("Filter order is zero - check the input parameters!"); return filterOrder; }    }### Answer:
@Test public void testCalculateFilterOrder() throws BadFilterParametersException { int filterOrder = iirdesigner.calculateFilterOrder(FilterType.LOWPASS, new double[] {10, 0.0}, new double[] {20, 0.0}, 5, 40, true); assertEquals(7, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.LOWPASS, 0.1, 0.2, 3.0, 40.0, false); assertEquals(7, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.HIGHPASS, new double[] {20, 0.0}, new double[] {10, 0.0}, 3, 20, true); assertEquals(4, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.BANDSTOP, new double[] {1, 4}, new double[] {2, 3}, 3, 20, true); assertEquals(3, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.BANDPASS, new double[] {2, 4}, new double[] {1, 5}, 5.0, 50.0, true); assertEquals(11, filterOrder); filterOrder = iirdesigner.calculateFilterOrder(FilterType.BANDPASS, new double[] {0.2, 0.4}, new double[] {0.1, 0.5}, 5.0, 50.0, false); assertEquals(9, filterOrder); }