CSC300 / CSC402: Does this work? [3/14] Previous pageContentsNext page

01
02
03
04
05
06
07
08
09
10
11
  public static int numFives (double[] a) {
    return numFives (a, 0, 0);
  }
  private static int numFives (double[] a, int i, int result) {
    if (i>=a.length) 
      return result;
    if (a[i] == 5.0) 
      numFives (a, i+1, result+1);
    else
      numFives (a, i+1, result);
  }

Previous pageContentsNext page