Set elements of passing to true whenever the parallel value of scores is a certain number or above?

Viewed 25

The method (public static void processPass(boolean[] passing, double[] scores, int length) should accept passing, scores, and length as parameters and it must set the elements of passing to true when the parallel value of scores is 60 or more than 60.

I just started Programming II and everything got very complicated. I have the first part of the lab (which I didn't mention) but I have no clue what I did in the last method.

This website is always really helpful, I appreciate that.

public static void main(String[] args) throws IOException {
    boolean[] isPassing = new boolean[100];
    double[] scores = new double[100]; 

    getData(scores);
    
}

public static int getData(double scores[]) throws FileNotFoundException {
    
    File fileIn = new File("lab1data.txt");
    
    int length = 0;
            
    Scanner infile = new Scanner(fileIn);
    
    while(infile.hasNext()) {
        
    scores[length] = infile.nextDouble();
    
    length +=1;
    }
    
    for(int i = 0; i < length; i++) {
        System.out.println(scores[i] + "\n");
    }
    
    System.out.println("Length: " + length);
    
    infile.close();
    
    return length;  
    
    
    
}

//this is what I am struggling with

public static void processPass(boolean[] passing, double[] scores, int length) {
    if(length <= 60) {
        passing[length] = true;
    }

    System.out.println(passing[length]);
    
}

}

0 Answers
Related