-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSistemaEscolar.java
More file actions
75 lines (58 loc) · 1.98 KB
/
Copy pathSistemaEscolar.java
File metadata and controls
75 lines (58 loc) · 1.98 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.Scanner;
public class SistemaEscolar {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] aluno = cadastrarAluno(sc);
double[] notas = cadastrarNotas(sc);
double media = calcularMedia(notas);
String situacao = verificarSituacao(media);
exibirBoletim(aluno[0], aluno[1], media, situacao);
sc.close();
}
// Cadastrar aluno
public static String[] cadastrarAluno(Scanner sc) {
System.out.print("Nome do aluno: ");
String nome = sc.nextLine();
System.out.print("Matrícula: ");
String matricula = sc.nextLine();
return new String[]{nome, matricula};
}
// Cadastrar notas
public static double[] cadastrarNotas(Scanner sc) {
System.out.print("Quantas notas? ");
int qtd = sc.nextInt();
double[] notas = new double[qtd];
for (int i = 0; i < qtd; i++) {
System.out.print("Nota " + (i + 1) + ": ");
notas[i] = sc.nextDouble();
}
return notas;
}
// Calcular média
public static double calcularMedia(double[] notas) {
double soma = 0;
for (double nota : notas) {
soma += nota;
}
return soma / notas.length;
}
// Verificar situação
public static String verificarSituacao(double media) {
if (media >= 7.0) {
return "Aprovado";
} else if (media >= 5.0) {
return "Recuperação";
} else {
return "Reprovado";
}
}
// Exibir boletim
public static void exibirBoletim(String nome, String matricula,
double media, String situacao) {
System.out.println("\n=== BOLETIM ===");
System.out.println("Aluno: " + nome);
System.out.println("Matrícula: " + matricula);
System.out.printf("Média: %.2f%n", media);
System.out.println("Situação: " + situacao);
}
}