-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlumno.java
More file actions
33 lines (29 loc) · 1.16 KB
/
Alumno.java
File metadata and controls
33 lines (29 loc) · 1.16 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
public class Alumno {
private String nombre;
private double[] calificaciones;
public Alumno(String nombre, double[] calificaciones) {
this.nombre = nombre;
this.calificaciones = calificaciones;
}
public double calcularPromedio(double[] notas) {
double suma = 0;
for (double nota : notas) { suma += nota; }
return suma / notas.length;
}
public char obtenerCalificacionFinal(double promedio) {
if (promedio <= 50) return 'F';
else if (promedio <= 60) return 'E';
else if (promedio <= 70) return 'D';
else if (promedio <= 80) return 'C';
else if (promedio <= 90) return 'B';
else return 'A';
}
public void imprimirResultados(String estudiante, double prom, char letraCalificacion) {
System.out.println("Nombre del estudiante: " + estudiante);
for (int i = 0; i < calificaciones.length; i++) {
System.out.println("Calificación " + (i + 1) + ": " + calificaciones[i]);
}
System.out.println("Promedio: " + prom);
System.out.println("Calificación: " + letraCalificacion);
}
}