Sie sind auf Seite 1von 1

int edad[], tam, comp=0, x=0;

String valor, nombre[];


tam = Integer.parseInt(jTextField1.getText().toUpperCase());
nombre = new String [tam];
edad = new int [tam];
for(int i=0;i<1;i++){
for(int j=0;j<tam;j++){
nombre[j] = JOptionPane.showInputDialog("Digite nombre de la "+
(j+1)+" persona").toUpperCase();
if(nombre[j].equals("")){
j=tam;
}else{
valor = JOptionPane.showInputDialog("Digite edad de "+nombre
[j]);
edad[j] = Integer.parseInt(valor);
}
}
if(edad[tam-1]!=0){
valor = JOptionPane.showInputDialog(null, "digite numero a comp
arar");
comp = Integer.parseInt(valor);
JOptionPane.showMessageDialog(null, "edad(es) mayor(es) a "+com
p);
int n=0;
while(x<0){
if(edad[x]>comp){
n += 1;
JOptionPane.showMessageDialog(null, "Nombre:"+nombre[x]
+"\nEdad:"+edad[x]);
}
if(n == 0){
JOptionPane.showMessageDialog(null, "No ahi personas co
n edades mayores a "+comp);
}
x += 1;
}
}
}

Das könnte Ihnen auch gefallen