I need to average 20 numbers and have all numbers smaller than average.
package pag1;
import java.util.Arrays;
import java.util.Scanner;
public class ex2 {
public static void main (String[] args){
Scanner x = new Scanner(System.in);
int soma = 0;
int posicao = 0;
double [] numeros = new double [20];
System.out.println("Digite 20 números para obter a média dos mesmos:");
while (posicao < numeros.length){
numeros [posicao] = x.nextDouble();
posicao++;
}
System.out.println(Arrays.toString(numeros));
for(int i=0; i<numeros.length; i++){
soma += numeros[i];
}
int media = soma / numeros.length;
System.out.println("soma: " + soma);
System.out.println(media);
}
}
There was only part of showing the numbers smaller than the average, but I have no idea how.