Java 案例3没有';t进入循环,案例5不';Don’不要把雇员的名字排得很整齐

Java 案例3没有';t进入循环,案例5不';Don’不要把雇员的名字排得很整齐,java,arrays,Java,Arrays,我正在开发一个应用程序,它必须执行以下操作: 我们将开发一个银行应用程序,为我们节省分行(数字)和每个分行的员工。这个应用程序应该要求屏幕显示银行有多少家分行,然后每个分行有多少员工在那里工作(Java中的多维数组) 用户将通过屏幕向我们提供每个分支机构编号的员工,并将其姓名、名字和第二姓氏传递给我们 保存所有数据后,屏幕上将显示一个菜单,在以下选项之间进行选择: 筛选其中一个分支机构(用户选择的分支机构)的所有员工。 屏幕显示员工所属的分支机构(用户选择的分支机构)。 显示有多少名员工具有相同

我正在开发一个应用程序,它必须执行以下操作:

我们将开发一个银行应用程序,为我们节省分行(数字)和每个分行的员工。这个应用程序应该要求屏幕显示银行有多少家分行,然后每个分行有多少员工在那里工作(Java中的多维数组)

用户将通过屏幕向我们提供每个分支机构编号的员工,并将其姓名、名字和第二姓氏传递给我们

保存所有数据后,屏幕上将显示一个菜单,在以下选项之间进行选择:

筛选其中一个分支机构(用户选择的分支机构)的所有员工。 屏幕显示员工所属的分支机构(用户选择的分支机构)。 显示有多少名员工具有相同的名字(用户选择的名字)。 筛选银行的员工总数。 按字母顺序显示中心中的所有员工

public class Banco2 {
    public static void main(String[] args) {
        //Scanner construction
        Scanner Entrada=new Scanner(System.in);//Scanner used to read Strings
        Scanner ent=new Scanner(System.in);//Scanner used to read Integer variables 
        //----------------------------------------------------------------------//
        //Variables used for the problem
        int sucursales;
        int options;
        int numsucursal;//Variable used for the case 1
        int numbempleados;//Variable used for the case 1
        int numeroempleado;
        String surname;
        String empleados;//Variable used for the case 2
        String Apellido;//Varible used for the case 3
        int empl;
        int numeroempleadototal=0;//Variable used as a counter in the case 4
        int aux=0;//Variable used in case 5 to go counting
        //--------------------------------------------------------------------------------//
        //We ask the user for the number of branches
        System.out.println("Introduce el numero de sucursales");
        sucursales=ent.nextInt();//We read the number of branches that the user introduces
        //Construction of our multidimensional array
        String banco [][]=new String[sucursales][];
        // i rows, j columns
        //In this loop we fill in the position
        for (int i=0;i<banco.length;i++) {
            System.out.println("Introduceme la cantidad de empleados que trabajan en la sucursal " + ( i+1 ));
            numeroempleado=ent.nextInt();
            //We assign it to the object bank 
            banco[i]=new String[numeroempleado];
        }
        //We are going to fill in the array
        for (int i=0;i<banco.length;i++) {
            for(int j=0;j<banco[i].length;j++) {
                System.out.println("Introduceme el nombre de los empleados " + ( i+1));//We use i+1 to know the branches that the user is filliing in 
                banco[i][j]=Entrada.nextLine(); 
            }
        }
        //--------------------------------------------------------------------------------------------------------//
        do {
        //Menu options
        System.out.println("Ingrese una de las opciones que desea hacer");
        System.out.println("1.Sacar por pantalla todos los empleados de unas sucursales");
        System.out.println("2.Sacar por pantalla a qué sucursal pertenece un empleado");
        System.out.println("3.Sacar por pantalla cuántos empleados hay con el mismo primer apellido");
        System.out.println("4.Sacar por pantalla cuántos empleados hay en total en el Banco.");
        System.out.println("5.Saca por pantalla todos los empleados del centro ordenados alfabéticamente.");
        //We read the option introduced
        options=ent.nextInt();
        switch(options) {
            case 1:
                System.out.println("Introduce la sucursal del empleado");
                numsucursal=ent.nextInt();
                System.out.println("Introduce el numero del empleado");
                numbempleados=ent.nextInt();
                System.out.println("El empleado es " + banco [numsucursal-1] [numbempleados]);
            break;
            case 2:
                System.out.println("Dime el nombre del empleado");
                empleados=Entrada.nextLine();
                //We go through the array to know the worker of the branch 
                for (int i=0;i<banco.length;i++) {
                    for (int j=0;j<banco[i].length;j++) {
                        if(empleados.equalsIgnoreCase(banco[i][j])) {
                        System.out.println("El empleado pertenece a la siguiente sucursal: " + (i + 1));
                    }//end of the second for
                }//end of the first for 
            }
            break;
            case 3: 
                //We ask the user for the surname
                System.out.println("Dime el apellido del empleado");
                //We read the surname introduced by the user
                Apellido=Entrada.nextLine();
                //We do two loops in order to go through the array
                for(int i=0;i<banco.length;i++) {
                    for (int j=0;j<banco.length;j++) {
                        surname=banco[i][j].substring(banco[i][j].indexOf(""),+1);
                        surname=Apellido.substring(0,Apellido.indexOf(""));
                        if(Apellido.equalsIgnoreCase(surname)) {
                            System.out.println("Los empleados con el apellido que quieres saber son: " +banco[i][j]);
                        }
                    }
                }
            break;
            case 4:
                    for (int i=0;i<banco.length;i++){
                        for (int j=0;j<banco[i].length;j++) {
                        numeroempleadototal ++;
                        System.out.println("Este es el numero total de empleados que hay en las sucursales " + numeroempleadototal);
                    }
                    }
            case 5:

                //We create the array with the names to order 
                String ordernames[] = new String[numeroempleadototal];
                aux=0;
                Arrays.sort(ordernames);
                for(int i=0;i<ordernames.length;i++) {
                    System.out.println("Nombres" + ordernames[i]);

                }
                break;
            default:
            System.out.println("Ha elegido usted la opcion incorrecta");
            break;
        }       
        }while(options!=6);
    }//end of main
}//end of class

公共类Banco2{
公共静态void main(字符串[]args){
//扫描仪结构
Scanner Entrada=new Scanner(System.in);//用于读取字符串的扫描仪
Scanner ent=new Scanner(System.in);//用于读取整数变量的Scanner
//----------------------------------------------------------------------//
//用于该问题的变量
内苏库萨雷斯;
int选项;
int numsucursal;//用于案例1的变量
int numbermpleados;//用于案例1的变量
整数复数;
串姓;
字符串empleados;//用于案例2的变量
字符串Apellido;//用于案例3的变量
国际雇员;
int numerioEmpleADOtotal=0;//在案例4中用作计数器的变量
int aux=0;//在第5种情况下使用的变量to go计数
//--------------------------------------------------------------------------------//
//我们向用户询问分支的数量
System.out.println(“引入成功的数字”);
sucursales=ent.nextInt();//我们读取用户引入的分支数
//多维数组的构造
字符串banco[][]=新字符串[sucursales][];
//i行,j列
//在这个循环中,我们填充位置

for(int i=0;在案例3中,您正在使用for(int j=0;j感谢您的帮助Adnan:)已解决:)