elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Temas
Páginas: [1]
1  Programación / Java / Problemas con los array en: 26 Mayo 2018, 15:45 pm
Hola gente quisiera saber si alguien puede darme un empujon con este codigo:

Código
  1. package buscar;
  2. import javax.swing.JOptionPane;
  3.  
  4. public class Buscar {
  5.  
  6.    public static void main(String[] args) {
  7.         boolean confirmacion = true;
  8.       int i,j =0;
  9.  
  10.    String [] jr = new String[2];//creamos un arreglo para nombres
  11.  
  12.   int [] gr = new int [2];// creamos un arreglo para telefono
  13.  
  14.   while (confirmacion ==true){  
  15.    int a = Integer.parseInt( JOptionPane.showInputDialog("\n______Agenda_____ \n"
  16.                + "1         Cargar Operarios\n"
  17.                + "2         Buscar Por Nombre\n"
  18.                + "3         Buscar Por Telefono\n"
  19.                + "4                Salir"));
  20.  
  21.        if (a ==1){    
  22.        String p = JOptionPane.showInputDialog(" Ingrese el nombre del Operario ");
  23.        JOptionPane.showMessageDialog(null,"Ingrese el telefono  de "+ p);  
  24.        for (i=0; i<jr.length-1;i++){
  25.  
  26.        jr [i+1] =p;
  27.        }
  28.  
  29.        for (j=0; j<gr.length-1; j++){
  30.  
  31.            int telefono = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el Numero de Telefono "));
  32.              gr[i+1]= telefono;
  33.        }
  34.  
  35.        }
  36.       if (a== 2){
  37.  
  38.           String oper= JOptionPane.showInputDialog(null, "Ingrese el nombre del operario a Buscar");
  39.          for(i =0; i<gr.length;i++){
  40.           if (jr[i] == oper && jr[i]!= oper){
  41.  
  42.               JOptionPane.showMessageDialog(null,"El telefono del operario "+oper+" es: "+jr[i] );
  43.  
  44.           }
  45.           else{
  46.               JOptionPane.showMessageDialog(null, "Aca estoy");
  47.           }
  48.          }
  49.  
  50.       if (a==3){
  51.         int  tel=Integer.parseInt( JOptionPane.showInputDialog(null, "Ingrese el telefono del operario a Buscar"));
  52.  
  53.         if (tel == gr[i]){
  54.             JOptionPane.showMessageDialog(null,"El operario es "+gr[i]);
  55.         }
  56.       }
  57.       if (a==4){
  58.           System.exit(0);
  59.       }
  60.   //como convertir un while a true o false usando JOptionPane confirm dialog....
  61.    //int  operacion = (JOptionPane.showConfirmDialog(null,"Desea cargar mas operarios y telefonos", "Confirmacion", JOptionPane.YES_NO_OPTION));
  62.           // if (operacion == 0){
  63.             //  confirmacion = true;
  64.            //}else
  65.               // if (operacion ==1 ){
  66.                  //  System.exit(0);
  67.  
  68.    }
  69.   }
  70.  
  71.    }
  72. }

la idea es que cargues operarios con su teléfono y luego a través del menú puedas buscarlos o por nombre o por el teléfono
el código se que esta algo bien pero no se donde esta el problema.
Gracias.
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines