This question already has an answer here:
So I'm trying to write a program for someone that reads 10 random numbers into an array. I want it to read and compute the average of the 10 numbers then go back and list the numbers that are smaller than the average. I was told to use decimal division. Heres what I have-
Random rd = new Random();
int[] array = new int[10];
for(int shelf = 0; shelf < 10; shelf++)
{
array[shelf] = rd.nextInt(10 - 1);
System.out.println(array[shelf]);
}
It currently just prints the 10 indices. I need it to find the average using decimal division and then print out all of the numbers that are below the average. Please use meaningful variable names.
Aucun commentaire:
Enregistrer un commentaire