Вы находитесь на странице: 1из 3

LEER EDAD

INGRESAR DATOS
REPORTAR DATOS
REPORTAR MAYORES
REPORTAR MENORES
EDAD PROMEDIO
MENORES O IGUALES AL PROMEDIO
EDAD MENOR

import java.io.*;
public class E4
{static BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
public static void main(String[]args)throws IOException

{int edad[]=new int[100];


int N, i, cm=0, sum=0, s=0, men, prom, c=0;
do{System.out.print("Ingrese cantidad de N=");
N=Integer.parseInt(br.readLine());
}while(N<=0 || N>100);

for(i=0 ; i<N ; i++)


{ do{System.out.print("Ingrese edad["+i+"]:");
edad[i]=Integer.parseInt(br.readLine());
} while(edad[i]<=0);
}
System.out.print("\nReporte todas las edades");
for(i=0 ; i<N ; i++)
{System.out.println("\nedad["+i+"]="+edad[i]);
}

System.out.print("\nReporte todas las edades mayores de edad");

for(i=0 ; i<N ; i++)


{if(edad[i]>=18)

{System.out.println("\nedad["+i+"]="+edad[i]);
cm++;
}
}
System.out.print("\nTodas las edades mayores de edad"+cm);

System.out.print("\nReporte todas las edades menores de edad");


for(i=0 ; i<N ; i++)
{if(edad[i]<18)

{System.out.println("\nedad["+i+"]="+edad[i]);
sum=sum+edad[i];
}
}

System.out.print("\nLa suma de menores de edad" +sum);

System.out.print("\n\nReporte de la edad promedio");


for(i=0 ; i<N ; i++){

s=s+edad[i];
}
prom=s/N;

System.out.print("\nLa edad promedio" +prom);

System.out.print("\n\nReporte de edades menores o iguales al promedio");


for(i=0 ; i<N ; i++){
if(edad[i]<=prom){

System.out.print("\nedad["+i+"]="+edad[i]);
c++;
}
System.out.print("\nEn total son=" +c);

System.out.print("\nReporte de edad menores");


men=edad[0];
for(i=0 ; i<N ; i++){
if(edad[i]<men){
men=edad[i];
}
}
System.out.print("\nLa edad menor es" +men);
}

}
}

Вам также может понравиться