Computer Science, asked by aratrika22, 11 months ago

WAP to input 15 numbers in an array and print the average of all odd numbers entered​

Answers

Answered by charlie1505
1

Explanation:

Basic logic for the given program

public static int average(int[] n, boolean even) {

int total = 0;

int count = 0;

for (int i = 0; i < n.length; i++) {

if (even == (n % 2 == 0)) {

total += n;

count ++;

}

}

if (count == 0)

return 0;

return total / count;

Similar questions