CSC300: Does this work? [11/12] Previous pageContentsNext page

01
02
03
04
05
06
07
08
09
10
11
12
13
  public static int numFives (double[] a) {
    int result = 0;
    int i = 0;
    while (i < a.length) {
      if (a[i] == 5.0) {
        result++; 
        i++;
      }
      if (a[i] != 5.0)  
        i++;
    }
    return result;
  }

Previous pageContentsNext page