Skip to content

Instantly share code, notes, and snippets.

@LucasHayashi
Last active January 23, 2024 23:26
Show Gist options
  • Save LucasHayashi/b02ea1ee0045925353dd49c321e4773b to your computer and use it in GitHub Desktop.
Save LucasHayashi/b02ea1ee0045925353dd49c321e4773b to your computer and use it in GitHub Desktop.
Calcular Média dos 50 Alunos
import java.util.Scanner;
public class Media {
public static void main(String args[]) {
int i = 0, soma = 0;
float media = 0;
int notas[] = new int[50];
Scanner entrada = new Scanner(System.in);
for ( i = 0 ; i < notas.length ; i++ ) {
System.out.println("Digite a nota do aluno " + (i+1) + ":");
int nota = entrada.nextInt();
notas[i] = nota;
soma+=nota;
}
media = soma / notas.length;
System.out.println("A media das " + notas.length + " notas digitadas e: " + media);
}
}
@LucasHayashi
Copy link
Author

Para testar com uma quantidade diferente de médias, basta trocar o tamanho do vetor notas[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment