Question

import java.util.Random; import java.util.ArrayList; /** * */ public class hw5_task8 { public static void main(String[] args)...

import java.util.Random;
import java.util.ArrayList;
/**
 *
 */
public class hw5_task8 {

    public static void main(String[] args) {
        int[] grades = randomIntArr(10);
        printIntArray("grades", grades);
        ArrayList<Integer> indexesF_AL = selectIndexes_1(grades);
        System.out.println(" indexesF_AL:    " + indexesF_AL);
        int[] indexesF_Arr = selectIndexes_2(grades);
        printIntArray("indexesF_Arr",indexesF_Arr);
    }
    
 
    public static int[] randomIntArr(int N){
        int[] res = new int[N];
        Random r = new Random(0);
        for(int i = 0; i < res.length; i++){
            res[i] = r.nextInt(101); // r.nextInt(101) returns an in in range [0, 100]
        }
        return res;
    }
    
    public static void printIntArray(String name, int[] a) {
        System.out.printf("%12s: ", name);
        if (a == null) {
            System.out.printf("Null array!\n\n");
            return;
        }

        for (int i = 0; i < a.length; i++) {
            System.out.printf("%5d", a[i]);
        }
        System.out.printf("\n");
    }
    
}

File hw5_task8.java contains an incomplete program. Complete that program by defining the following two functions that return the indexes of the grades that are strictly smaller than 60:

selectIndexes_1 function, that returns the indexes as an arrayList of integers.

selectIndexes_1 function, that returns the indexes as an array of integers.

Sample output:

      grades:    67   72   93    5    9   54   82   42   84   98
 indexesF_AL:    [3, 4, 5, 7]
indexesF_Arr:     3    4    5    7
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
import java.util.Random; import java.util.ArrayList; /** * */ public class hw5_task8 { public static void main(String[] args)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT