2
How do I make a Java algorithm that reads 3 numbers and averages? I know how to do it without repeating structure, but how to do it with repeating structure?
Follow my code below, but do not have the expected result:
public class NotaAluno {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int notaAluno[] = new int[3];
int i;
double media = 0;
for(i = 0; i < notaAluno.length; i++){
System.out.println("Informe o numero da nota do aluno [" + notaAluno[i]+"]" );
notaAluno[i] = entrada.nextInt();
media = (notaAluno.length)/ 3;
}
System.out.println("A Media dos alunos eh " + media);
}
}
I have tried to do this way media = (notaAluno[i]) / 3 however unsuccessfully
– Everson Souza de Araujo
You need a vector for that?
– user28595