-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlunosNotas.java
51 lines (42 loc) · 1.41 KB
/
AlunosNotas.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
/**
* Laboratório de Programação 2 - Lab 1
*
* @author Pedro Manoel
*/
public class AlunosNotas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int maiorNota = 0;
int menorNota = 1000;
int media = 0;
int numNotas = 0;
int numNotasAcima = 0;
int numNotasAbaixo = 0;
while(true) {
String[] linha = sc.nextLine().split(" ");
if (linha[0].equals("-")) { break; }
int nota = Integer.parseInt(linha[1]);
// Somando a nota a média e aumentando a contagem de notas lidas
media += nota;
numNotas += 1;
// Maior Nota
if (nota > maiorNota ) { maiorNota = nota; }
// Menor Nota
if (nota < menorNota ) { menorNota = nota; }
// Contabilizando as notas abaixo, acima ou igual a 700
if (nota >= 700) {
numNotasAcima += 1;
} else {
numNotasAbaixo += 1;
}
}
// Exibindo os resultados
System.out.format("maior: %d\n", maiorNota);
System.out.format("menor: %d\n", menorNota);
System.out.format("media: %d\n", media / numNotas);
System.out.format("acima: %d\n", numNotasAcima);
System.out.format("abaixo: %d", numNotasAbaixo);
sc.close();
}
}