0

I am trying to make a method that allows a Manager or Employee to be able to add customers with the traits fname, lname, address, city, state, and zip. I want to store this data in String [][] customerData = new String[30][6], with 30 max customers and 6 traits. However, no matter what I do, the array always ends up null, with nothing in it. Here is my code:

    public void addCustomer() throws FileNotFoundException {
        String fname = "";
        String lname = "";
        String address = "";
        String city = "";
        String state = "";
        String zip = "";
        int howManyCustomers = 0;
        int traits = 6;

        System.out.println("how many customer would you like to add");
        howManyCustomers = scan.nextInt();

        for(int i=0; i < customerData.length; i++)
           {
              System.out.println("enter customer data (fname, lname, address, city, state, zip");
               for(int j=0; j < customerData[i].length; j++)
               {
                   customerData[i][j] = scan.nextLine();
               }
           }

Output:

how many customer would you like to add
1
enter customer data (fname, lname, address, city, state, zip
first name
last name
123 Address Dr
City
State
enter customer data (fname, lname, address, city, state, zip

It doesn't let me scan ZIP and it also loops and asks me again. I know that none of the variables are used, but I wasn't sure if I had to use them at some point -- just kind of lost.

0 Answers0