Vous êtes sur la page 1sur 1

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package topicos;
/**
*
* @author Eliud
*/
import javax.swing.*;
public class AlumnoCalif{
private Alumno alumnos[];
public AlumnoCalif(int n){
alumnos=new Alumno[n];
}
public void agregar(){
for (int i=0; i<alumnos.length; i++) {
String nom=JOptionPane.showInputDialog("Ingresa el nombr
e");
int cal=Integer.parseInt(JOptionPane.showInputDialog("In
gresa la calificacion"));
alumnos[i]=new Alumno(nom,cal);
JOptionPane.showMessageDialog(null,"Se agrego correctame
nte el alumno: "+nom);
}
}
public int buscar(String nom){
for (int i=0; i<alumnos.length; i++) {
if(alumnos[i].getNombre().equals(nom))
return alumnos[i].getCalificacion();
}
return -1;
}
public static void main (String[]args){
int m=Integer.parseInt(JOptionPane.showInputDialog("De que taman
o quieres el arreglo"));
AlumnoCalif arreglo=new AlumnoCalif(m);
arreglo.agregar();
String nom= JOptionPane.showInputDialog("Ingresa el nomb
re del alumno que deseas buscar:\n");
int c=arreglo.buscar(nom);
if(c>-1)
JOptionPane.showMessageDialog(null,"La calificac
ion del alumno "+nom+" es: "+c);
else
JOptionPane.showMessageDialog(null,"El alumno: "
+nom+" NO EXISTE");
}
}

Vous aimerez peut-être aussi