title: How to use a loop to input data into arrays?
body: <p>I am trying to make a simple program where the user inputs employee information into a database for five employees; including name, age, wage, and an ID that is stored automatically. I seem to be having trouble however, getting the loop to work, and run into problems after the first array. I suspect there is a problem located within the for loop. Can anyone help me? Here is the code:</p>
  
  <pre><code>package database;
  
  import java.util.Scanner;
  /**
   *
   * @author Justin
   */
  public class employees {
      public static void main(String[] args) {
  
          Scanner scan = new Scanner(System.in);
          String[] names;
          names = new String[4];
          int[] id;
          id = new int[4];
          double[] wage;
          wage = new double[4];
          int[] age;
          age = new int[4];
          System.out.println("This program is designed to store data for 5 employees.\nEnter data for 5 employees\n");
  
          for (int count = 0; count &lt;= 4; count++){
              //Used to enter data for each employee
              id[count] = count;
              System.out.println("Enter the name of employee number " + id[count]);
              names[count] = scan.nextLine();
              System.out.println("Enter the wage of " + names[count]);
              wage[count] = scan.nextDouble();
              System.out.println("Enter the age of " + names[count]);
              age[count] = scan.nextInt();
          }
  
          System.out.println("All employees are now in the database.");
          System.out.println("Enter the name or ID number of an employee to access their data");
  
      }
  }
  </code></pre>