**********************************************
**********************************************
**********************************************
/*
* 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 fredest;
import javax.swing.JOptionPane;
/**
*
* @author laba32
*/
public class FredEst {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Grupo G = new Grupo();
int opcion;
do
{
opcion = Integer.parseInt(JOptionPane.showInputDialog("Ingrese su opcion\n 1.Ingrese un estudiante\n 2.Eliminar un estudiante\n 3.Agregar un docente\n 4.Eliminar un docente\n 5.PROMEDIO TOTAL\n 6.Mostrar Datos\n 7.SALIR"));
switch(opcion)
{
case 1:
G.agregarEstudiante();
break;
case 2:
G.eliminarEstudiante();
break;
case 3:
G.agregarDocente();
break;
case 4:
G.eliminarDocente();
break;
case 5:
G.calcularPromedioGrupal();
break;
case 6:
G.mostrarDatos();;
break;
}
}while(opcion !=7);
}
}
**********************************************
**********************************************
**********************************************
/*
* 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 fredest;
import static java.lang.Float.parseFloat;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
/**
*
* @author laba32
*/
public class Grupo
{
private String Codigo;
private Vector <Estudiante> Matriculados = new Vector <> ();
private ArrayList <Docente> Asesores = new ArrayList <> ();
public void agregarEstudiante()
{
Estudiante E = new Estudiante();
E.setCarnet(JOptionPane.showInputDialog("Ingrese el numero de carnet del estudiante\n"));
E.setNombreCompleto(JOptionPane.showInputDialog("Ingrese el nombre completo del estudiante\n"));
E.setPromedio(Float.parseFloat(JOptionPane.showInputDialog("Ingrese el promedio del estudiante\n")));
E.setSexo(Boolean.parseBoolean(JOptionPane.showInputDialog("Ingrese 1 para Masculino / 0 para Femenino\n")));
Matriculados.add(E);
}
public void eliminarEstudiante()
{
String par;
par = JOptionPane.showInputDialog("Ingrese el numero de carnet del estudiante a eliminar\n");
for(int i = 0; i < this.Matriculados.size(); i++)
{
if(this.Matriculados.get(i).getCarnet().equals(par))
{
Matriculados.remove(i);
}
}
}
public void agregarDocente()
{
Docente D = new Docente();
D.setCedula(JOptionPane.showInputDialog("Ingrese el numero de cedula de docente\n"));
D.setNombreCompleto(JOptionPane.showInputDialog("Ingrese el nombre del docente\n"));
Asesores.add(D);
}
public void eliminarDocente()
{
String par;
par = JOptionPane.showInputDialog("Ingrese el numero de cedula a eliminar\n");
for(int i = 0; i < this.Asesores.size(); i++)
{
if(this.Asesores.get(i).getCedula().equals(par))
{
Asesores.remove(i);
}
}
}
public void calcularPromedioGrupal()
{
float Prom = 0;
for(int i = 0; i < this.Matriculados.size(); i++)
{
Prom += Matriculados.get(i).getPromedio();
}
JOptionPane.showMessageDialog( null,"Promedio Total : "+Prom/Matriculados.size(),"Promedio Total",JOptionPane.INFORMATION_MESSAGE);
//System.out.println("-->"+Prom/Matriculados.size());
}
public void mostrarDatos()
{
for (int i=0; i<this.Matriculados.size();i++)
{
Estudiante E=Matriculados.get(i);
JOptionPane.showMessageDialog(null,
"Carnet : "+ E.getCarnet() + " \n" +
"Nombre : "+ E.getNombreCompleto() + " \n" +
"Promedio : "+ E.getPromedio() + " \n"
,"DATOS",JOptionPane.INFORMATION_MESSAGE);
}
}
}