Advertisement
Guest User

Media de alumnos

a guest
Nov 12th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. import java.lang.reflect.Array;
  2. import java.util.Scanner;
  3.  
  4. public class Ejercicio16 {//que descanses en paz, Programacion ATS (youtube); Alejandro :ยดc
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner in = new Scanner(System.in);
  8.         float alumnos[] = new float [5];
  9.         float primer, segundo, tercer;
  10.         float media=0, media_alumno;
  11.        
  12.         for(int i=0;i<5;i++) {
  13.             System.out.print("Ingrese la nota del alumno "+(i+1)+" primer trimestre: ");
  14.             primer=in.nextInt();
  15.            
  16.             System.out.print("Ingrese la nota del alumno "+(i+1)+" segundo trimestre: ");
  17.             segundo=in.nextInt();
  18.            
  19.             System.out.print("Ingrese la nota del alumno "+(i+1)+" tercer trimestre: ");
  20.             tercer=in.nextInt();
  21.            
  22.             alumnos[i]= (primer + tercer + segundo) / 3; //La media de cada alumno
  23.             media += alumnos[i];
  24.         }
  25.        
  26.         System.out.print("La nota media de todo el grupo es: " + media / Array.getLength(alumnos));
  27.        
  28.         System.out.print("Ahora, ingrese la ID del alumno que desea conocer su media: ");
  29.         primer=in.nextInt() - 1;
  30.        
  31.         System.out.print("La nota media es: " + alumnos[(int) primer]);
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement