help to close the program

0

Hello, I need to close this program but I have a couple of blunders.

I need if you can help me find the problem, the program consists of a student registry for scholarships, that the data is by console

this is the code.

package control8ok;

import javax.swing.JOptionPane;

public class CONTROL8OK {
int contar=0, nro=00001;

IngresoAlumno ingreso [] = new Ingreso alumno[3];

 public CONTROL8OK(){

    String ax;
    int op=0;

    do{
        ax = JOptionPane.showInputDialog(null, "1. INGRESO DE ALUMNO \n"
                                              +"2. LISTA DE ALUMNOS \n"
                                              +"3. SALIR ");

        if(ax!=null && !ax.equals("")){
            op = Integer.parseInt(ax);

            switch(op){
                case 1:
                    ingresar();
                    break;
                case 2:
                    mostrar();
                    break;
                case 3:
                    break;
                default:
                    JOptionPane.showMessageDialog(null, "ERROR, INGRESE UNA 
                    OPCION CORRECTA!!!");                  
            }
        }

    }while(op!=3);
}


public void ingresar(){        


    int nro = 0, telefono, ingresosfamiliares, ramoscursa, ramosaprobados;
    String nombre, apellido, direccion, beca, jornada, semestre ;       

    nombre = JOptionPane.showInputDialog(null, "INGRESE NOMBRES DEL ALUMNO: 
    ");
    apellido = JOptionPane.showInputDialog(null, "INGRESE EL APELLIDOS DEL 
    ALUMNO:");
    direccion = JOptionPane.showInputDialog(null, "INGRESE LA DIRECCION DEL 
    ALUMNO: ");
    telefono = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE 
    EL TELEFONO DEL ALUMNO: "));
    ingresosfamiliares = Integer.parseInt(JOptionPane.showInputDialog(null, 
    "INGRESE INGRESOS FAMILIARES: "));
    beca = JOptionPane.showInputDialog(null, "INGRESE BECA A POSTULAR EL 
    ALUMNO");
    jornada = JOptionPane.showInputDialog(null, "INGRESE LA JORNADA EN LA 
    QUE ESTUDIA EL ALUMNO");
    ramoscursa = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE 
    LA CANTIDAD DE RAMOS QUE CURSA EL ALUMNO"));
    ramosaprobados = Integer.parseInt(JOptionPane.showInputDialog(null, 
    "INGRESE LOS RAMOS APROBADOS DEL ALUMNO"));
    semestre = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE 
    EL SEMESTRE EN EL QUE SE ENCUENTRA EL ALUMNO"));

    IngresoAlumno ing = new IngresoAlumno();

   ing.setNro(nro); 
   ing.setNombre(nombre); 
   ing.setApellido(apellido);
   ing.setDireccion(direccion);
   ing.setTelefono(telefono);
   ing.setIngresosfamiliares(ingresosfamiliares);
   ing.setBeca(beca);
   ing.setJornada(jornada);
   ing.setRamoscursa(ramoscursa);
   ing.setRamosaprobados(ramosaprobados);
   ing.setSemestre(semestre);

    ingreso[contar] = ing;
    contar++;  
    nro++;      
}

private void mostrar(){

    String ay="";

    for(int i=0; i<contar; i++){
        ay+="NUMERO DE REGRISTRO ALUMNO:  "+ingreso[i].getNro()+"\n"
          + "NOMBRE DEL ALUMNO:           "+ingreso[i].getNombre()+"\n"
          + "APELLIDO DEL ALUMNO:         "+ingreso[i].getApellido()+"\n"
          + "DIRECCION DEL ALUMNO:        "+ingreso[i].getDireccion()+"\n"
          + "TELEFONO DEL ALUMNO:         "+ingreso[i].getTelefono()+"\n"
          + "INGRESOS FAMILIARES:         
         "+ingreso[i].getIngesosfamiliares()+"\n"
          + "BECA POSTULADA:              "+ingreso[i].getBeca()+"\n"
          + "JORNADA DEL ALUMNO:          "+ingreso[i].getJornada()+"\n"
          + "RAMOS QUE CURSA EL ALUMNO:   "+ingreso[i].getRamoscursa()+"\n"      
          + "RAMOS APROBADOS:             
          "+ingreso[i].getRamosaprobados()+"\n"
          + "SEMESTRE QUE ESTA EL ALUMNO: "+ingreso[i].getSemestre()+"\n\n";      
          JOptionPane.showMessageDialog(null, ay);
           }
        }
       public static void main(String[] args) {

          IngresoAlumno ay;
          ay = new IngresoAlumno();
          System.exit(0);        
        }
      }           
   package control8ok;


   public class IngresoAlumno extends CONTROL8OK {


   public int nro;
   public int telefono, ingresosfamiliares, ramoscursa, ramosaprobados; 
   public String nombre, apellido, direccion, beca, jornada, semestre ;

   public int getNro() {
     return nro;
   }

   public void setNro(int nro) {
    this.nro = nro;
   }


   public String getNombre() {
     return nombre;
   }

   public void setNombre(String nombre) {
      this.nombre = nombre;
   }

   public String getApellido() {
     return apellido;
   }

   public void setApellido(String apellido) {
    this.apellido = apellido;
  }

 public String getDireccion() {
    return direccion;
 }

 public void setDireccion(String direccion) {
    this.direccion = direccion;
  }

 public int getTelefono() {
    return telefono;
}

  public void setTelefono(int telefono) {
    this.telefono = telefono;
}

  public int getIngresosfamiliares() {
    return ingresosfamiliares;
}

 public void setIngresosfamiliares(int ingresosfamiliares) {
    this.ingresosfamiliares = ingresosfamiliares;
}

 public String getBeca() {
    return beca;
}

public void setBeca(String beca) {
    this.beca = beca;
}

 public String getJornada() {
    return jornada;
}

  public void setJornada(String jornada) {
    this.jornada = jornada;
}

 public int getRamoscursa() {
    return ramoscursa;
}

 public void setRamoscursa(int Ramoscursa) {
    this.ramoscursa = ramoscursa;
}

 public int getRamosaprobados() {
    return ramosaprobados;
}

 public void setRamosaprobados(int ramosaprobados) {
    this.ramosaprobados = ramosaprobados;
}

 public int getSemestre() {
    return semestre;
 }

public void setSemestre(int semestre) {
    this.semestre = semestre;
    } 
 }
    
asked by Danilo Antonio Lopez Vega 23.10.2018 в 03:47
source

2 answers

0

You can create a 3rd option in which you can leave for example:

 switch(op){
            case 1:
                ingresar();
                break;
            case 2:
                mostrar();
                break;
            case 3:
                salir();
                break;
            default:
                JOptionPane.showMessageDialog(null, "ERROR, INGRESE UNA OPCION CORRECTA!!!");                  
        }

Making an exit function.

public void salir() {
System.exit(0);
}

Since you declare it in the main but in instances a class of which you have some functions but in if you can return to the function of your switch in case the user wants to re-enter and from there leave. If you have another question, ask in the comments.

    
answered by 23.10.2018 в 05:28
0

So far I have the following that I have improved, but when entering the data by console, after putting show does not show anything

package control8ok;

import javax.swing.JOptionPane;

public class CONTROL8OK {
 int contar=0, nro=00001;

IngresoAlumno ingreso [] = new IngresoAlumno[3];

 public CONTROL8OK(){

    String ax;
    int op=0;

    do{
        ax = JOptionPane.showInputDialog(null, "1. INGRESO DE ALUMNO \n"
                                              +"2. LISTA DE ALUMNOS \n"
                                              +"3. SALIR ");

        if(ax!=null && !ax.equals("")){
            op = Integer.parseInt(ax);

            switch(op){
                case 1:
                    Ingresar();
                    break;
                case 2:
                    Mostrar();
                    break;
                case 3:
                    Salir();
                    break;
                default:
                    JOptionPane.showMessageDialog(null, "ERROR, INGRESE UNA OPCION CORRECTA!!!");                  
            }
        }

    }while(op!=3);
}


public void Ingresar(){        


    int nro ;
    int telefono, ingresosfamiliares, ramoscursa, ramosaprobados, semestre;
    String nombre, apellido, direccion, beca, jornada;       

    nombre = JOptionPane.showInputDialog(null, "INGRESE NOMBRES DEL ALUMNO: ");
    apellido = JOptionPane.showInputDialog(null, "INGRESE EL APELLIDOS DEL ALUMNO: ");
    direccion = JOptionPane.showInputDialog(null, "INGRESE LA DIRECCION DEL ALUMNO: ");
    telefono = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE EL TELEFONO DEL ALUMNO: "));
    ingresosfamiliares = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE INGRESOS FAMILIARES: "));
    beca = JOptionPane.showInputDialog(null, "INGRESE BECA A POSTULAR EL ALUMNO");
    jornada = JOptionPane.showInputDialog(null, "INGRESE LA JORNADA EN LA QUE ESTUDIA EL ALUMNO");
    ramoscursa = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE LA CANTIDAD DE RAMOS QUE CURSA EL ALUMNO"));
    ramosaprobados = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE LOS RAMOS APROBADOS DEL ALUMNO"));
    semestre = Integer.parseInt(JOptionPane.showInputDialog(null, "INGRESE EL SEMESTRE EN EL QUE SE ENCUENTRA EL ALUMNO"));

    IngresoAlumno ing = new IngresoAlumno();

   ing.setNro(nro); 
   ing.setNombre(nombre); 
   ing.setApellido(apellido);
   ing.setDireccion(direccion);
   ing.setTelefono(telefono);
   ing.setIngresosfamiliares(ingresosfamiliares);
   ing.setBeca(beca);
   ing.setJornada(jornada);
   ing.setRamoscursa(ramoscursa);
   ing.setRamosaprobados(ramosaprobados);
   ing.setSemestre(semestre);

    ingreso[contar] = ing;
    contar++;  
    nro++;      
}

private void Mostrar(){

    String ay="";

    for(int i=0; i<contar; i++){
        ay+="NUMERO DE REGRISTRO ALUMNO:  "+ingreso[i].getNro()+"\n"
          + "NOMBRE DEL ALUMNO:           "+ingreso[i].getNombre()+"\n"
          + "APELLIDO DEL ALUMNO:         "+ingreso[i].getApellido()+"\n"
          + "DIRECCION DEL ALUMNO:        "+ingreso[i].getDireccion()+"\n"
          + "TELEFONO DEL ALUMNO:         "+ingreso[i].getTelefono()+"\n"
          + "INGRESOS FAMILIARES:         "+ingreso[i].getIngresosfamiliares()+"\n"
          + "BECA POSTULADA:              "+ingreso[i].getBeca()+"\n"
          + "JORNADA DEL ALUMNO:          "+ingreso[i].getJornada()+"\n"
          + "RAMOS QUE CURSA EL ALUMNO:   "+ingreso[i].getRamoscursa()+"\n"      
          + "RAMOS APROBADOS:             "+ingreso[i].getRamosaprobados()+"\n"
          + "SEMESTRE QUE ESTA EL ALUMNO: "+ingreso[i].getSemestre()+"\n\n";      
    JOptionPane.showMessageDialog(null, ay);
}
}
private void Salir(){
    System.exit(0);
}
}
package control8ok;


public class IngresoAlumno extends CONTROL8OK {


    public int nro;
    public int telefono, ingresosfamiliares, ramoscursa, ramosaprobados, semestre; 
    public String nombre, apellido, direccion, beca, jornada;

public int getNro() {
        return nro;
    }

    public void setNro(int nro) {
        this.nro = nro;
    }


public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

public int getTelefono() {
        return telefono;
    }

    public void setTelefono(int telefono) {
        this.telefono = telefono;
    }

public int getIngresosfamiliares() {
        return ingresosfamiliares;
    }

    public void setIngresosfamiliares(int ingresosfamiliares) {
        this.ingresosfamiliares = ingresosfamiliares;
    }

public String getBeca() {
        return beca;
    }

    public void setBeca(String beca) {
        this.beca = beca;
    }

public String getJornada() {
        return jornada;
    }

    public void setJornada(String jornada) {
        this.jornada = jornada;
    }

public int getRamoscursa() {
        return ramoscursa;
    }

    public void setRamoscursa(int Ramoscursa) {
        this.ramoscursa = ramoscursa;
    }

public int getRamosaprobados() {
        return ramosaprobados;
    }

    public void setRamosaprobados(int ramosaprobados) {
        this.ramosaprobados = ramosaprobados;
    }

public int getSemestre() {
        return semestre;
    }

    public void setSemestre(int semestre) {
        this.semestre = semestre;
    }
}
    
answered by 23.10.2018 в 05:45