Answer:
Step-by-step explanation:
The following program is written in Java and creates the divBySum method using a enhanced for loop. In the picture attached below I have provided an example of the output given if called using the array provided in the question and a divisible parameter of 3.
public static int divBySum(int[] arr, int num) {
int sum = 0;
for (int x : arr) {
if ((x % num) == 0) {
sum += x;
}
}
return sum;
}