|
| 1 | +package unit05.Actividad17_Aplicacion; |
| 2 | + |
| 3 | +import java.util.Scanner; |
| 4 | + |
| 5 | +/* |
| 6 | + Debes desarrollar una aplicación que ayude a gestionar las notas de un centro educativo. |
| 7 | + Los alumnos se organizan en grupos compuestos por 5 personas. |
| 8 | + Leer las notas (números enteros) del primer, segundo y tercer trimestre de un grupo. |
| 9 | + Debes mostrar al final la nota media del grupo en cada trimestre y |
| 10 | + la media del alumno que se encuentra en una posición dada (que el usuario introduce por teclado). |
| 11 | + */ |
| 12 | +public class Actividad17 { |
| 13 | + public static void main(String[] args) { |
| 14 | + Scanner sc = new Scanner(System.in); |
| 15 | + int[][] notas = new int[5][3]; |
| 16 | + |
| 17 | + // Leer las notas de los alumnos |
| 18 | + for (int i = 0; i < notas.length; i++) { |
| 19 | + System.out.println("Alumno " + (i + 1)); |
| 20 | + for (int j = 0; j < notas[i].length; j++) { |
| 21 | + System.out.print("Nota trimestre " + (j + 1) + ": "); |
| 22 | + notas[i][j] = sc.nextInt(); |
| 23 | + } |
| 24 | + } |
| 25 | + // Mostramos la tabla |
| 26 | + System.out.println("Notas de los alumnos"); |
| 27 | + for (int i = 0; i < notas.length; i++) { |
| 28 | + System.out.print("Alumno " + (i + 1) + ": "); |
| 29 | + for (int j = 0; j < notas[i].length; j++) { |
| 30 | + System.out.print(notas[i][j] + " "); |
| 31 | + } |
| 32 | + System.out.println(); |
| 33 | + } |
| 34 | + |
| 35 | + // Mostrar las notas de los alumnos |
| 36 | + System.out.println("Notas Media de los Trimestres"); |
| 37 | + for (int i = 0; i < notas[0].length; i++) { |
| 38 | + int media = 0; |
| 39 | + System.out.println("Trimestre " + (i + 1) + ":"); |
| 40 | + for (int[] nota : notas) { |
| 41 | + media += nota[i]; |
| 42 | + } |
| 43 | + System.out.println("Media: " + (media / notas[i].length)); |
| 44 | + } |
| 45 | + |
| 46 | + // Mostrar la media de un alumno |
| 47 | + System.out.print("Introduce el número de alumno: "); |
| 48 | + int alumno = sc.nextInt(); |
| 49 | + |
| 50 | + int media = 0; |
| 51 | + for (int i = 0; i < notas[alumno - 1].length; i++) { |
| 52 | + media += notas[alumno - 1][i]; |
| 53 | + } |
| 54 | + System.out.println("Media del alumno " + alumno + ": " + (media / notas[alumno - 1].length)); |
| 55 | + } |
| 56 | +} |
0 commit comments