0
    Scanner input = new Scanner(System.in);

    String accounts[][] = new String[2][6];

    for (int i = 0; i < 2; i++) {

        System.out.print("\n\n\tClient Code : SGBK-ACC008" + (i+1) + "\n\n");

        for (int j = 0; j < 6; j++) {

            if (j == 0) {
                System.out.print("\n\tAccount Number : ");
            } else if (j == 1) {
                System.out.print("\n\tFull Name : ");
            } else if (j == 2) {
                System.out.print("\n\tID Number : ");
            } else if (j == 3) {
                System.out.print("\n\tAccount Type : ");
            } else if (j == 4) {
                System.out.print("\n\tInitial Amount : ");
            } else if (j == 5) {
                System.out.print("\n\tAccount State : ");
            } else {
                System.out.print("\n\tError!");
            }

            accounts[i][j] = input.nextLine();

        }
    }

    System.out.print("\n\tInput Full \n\n");

    for (int i = 0; i < 2; i++) {

        for (int j = 0; j < 6; j++) {

            System.out.print(accounts[i][j] + "  ");
        }

        System.out.println();
    }
}

}

So these lines of codes above actually work but when they're part of the bigger program i'm trying to make, they don't. I'm trying to write a bank application where information about the clients are stored inside of a multidimensional array.

    Scanner sc = new Scanner(System.in);
    int choice, reponse = 0;
    double operation;


    String stockCompte[][] = new String[2][6];

    System.out.print("\n\t********** WELCOME TO E-CORP **********\n\n");

    do {

        choice = 0;

        System.out.print("\n\t---MENU ---\n");

        System.out.print("\n\t\t 1 - Open an Account");
        System.out.print("\n\t\t 2 - Debit");
        System.out.print("\n\t\t 3 - Credit");
        System.out.print("\n\t\t 4 - Transfer");
        System.out.print("\n\t\t 5 - Close an Account");

        System.out.print("\n\n\tChoose an option : ");

        choice = sc.nextInt();

        switch (choice) {

        case 1:

            System.out.print("\n\t\tOpen an Account\n");

            for (int i = 0; i < 2; i++) {

                System.out.print("\n\tAutomatic Client Code : SGBK-ACC008" + (i + 1) + "\n");

                for (int j = 0; j < 6; j++) {

                    if (j == 0) {
                        System.out.println("\n\tCreeate an Account Number - (Format : 01) : ");
                    } else if (j == 1) {
                        System.out.println("\n\tFull Name - (Format : NOM Prenom) : ");
                    } else if (j == 2) {
                        System.out.print("\n\tID Number : ");
                    } else if (j == 3) {
                        System.out.print("\n\tAccount Type : ");
                    } else if (j == 4) {
                        System.out.print("\n\tInitial Amount : ");
                    } else if (j == 5) {
                        System.out.print("\n\tAccount State : ");
                    } else {
                        System.out.print("\n\tError!");
                    }

                    stockCompte[i][j] = sc.nextLine();
                }

            }

            System.out.print("\n\tInput Full!\n\n");

            for (int i = 0; i < 2; i++) {

                for (int j = 0; j < 6; j++) {

                    System.out.print(stockCompte[i][j] + "  ");
                }

                System.out.println();
            }

            break;

        case 2:

            System.out.print("\n\t\tDebit\n");

            break;

        case 3:

            System.out.print("\n\t\tCredit\n");

            break;

        case 4:

            System.out.print("\n\t\tTransfer\n");

            break;

        case 5:

            System.out.print("\n\t\tClose an Account\n");

            break;

        default:

            System.out.print("\n\tWrong Choice!");

            break;

        }

        do {

            System.out.print("\n\tContinue ? (1 - Continue / 2 - Stop) : ");
            reponse = sc.nextInt();

        } while (reponse != 1 && reponse != 2);

        System.out.print("\n\tSession Ended!");

    } while (reponse == 1);
}

}

In that case, the first line of input in the the array is successful but not the second. It doesn't take the first value of the second line of the array.

dyerlin
  • 1
  • 1

0 Answers0