mercredi 16 décembre 2020

How would you calculate the average of all odd numbers in a randomly generated array (has to be a method)

here's my code so far, I need a method to calculate and print out the average of the odd numbers in the array, I've tried so far but none of my tried methods work, help?

    public static void main(String[] args)      {
            int[] arr = new int[20];       
            for(int i = 0; i < arr.length; i++) {
                  arr[i] = (int)(Math.random()*999);



Aucun commentaire:

Enregistrer un commentaire