This is part of an ongoing project and up to now i've been able to figure things out. This insallment is:
1. Create an instance array called employees that will hold Employee elements.
2. Modify your loop to create a new element in the employees array for each employee entered by the user.
3. Create an input loop that allows the user to enter up to 26 payments per employee.
4. Allow the user to request a list of payments for a requested employee.
My code just keeps asking for employee name and I am trying to populate the array. I know I am missing it somewhere, can someone help me out? Here's my code

final int ROWS = 3;
final int COLS =26;

String[][] employees = new String[ROWS][COLS];
    for(int row=0; row<ROWS;row++){
        for(int col=0; col<COLS; col++){
System.out.println("Enter an employee");

String number = input.nextLine();
employees[row][col]=number;
}
}
for(int row=0; row<ROWS;row++){
for(int col=0; col<COLS; col++){

system.out.println(employees[row][col]);
}
}

Its going to ask for the employee name 78 times. so only after that will it print out your array. I would try changing COL's to 3 or something so you don't have to enter in so many numbers before getting them printed out.

1. Create an instance array called employees that will hold Employee elements.
2. Modify your loop to create a new element in the employees array for each employee entered by the user.
3. Create an input loop that allows the user to enter up to 26 payments per employee.
4. Allow the user to request a list of payments for a requested employee.
My code just keeps asking for employee name and I am trying to populate the array. I know I am missing it somewhere, can someone help me out? Here's my code

the way you describe it you want to enter the employee name in the outside loop and the payments in the inside loop.

It is only supposed to have 3 entries for name(row) and 26 elements for data(column). I would gladly change the amount but my instructor wouldnt like it. Thanks for your reply.

For the sake of debugging you can change it, Just have to change it back afterwalds.

Anyhow, It will take you 78 iterations and each time it will ask for an employee name, You don't want that I think. I think you are trying to get the pay for 26 of those iterations, now your not going to be able to store the name and the pay amounts in your array, to do that you will need COL+1 elements not COL ( Unless you want to store 25 pays )

String[][] employees = new String[ROWS][COLS];
for(int row=0; row<ROWS;row++){
	System.out.println("Please enter Employee Name :");
	String name = input.nextLine();
	employees[row][0]=name;

        for(int col=1; col<COLS; col++){
		System.out.println("Please enter Employee: " + row + " Pay: " + col);
		String number = input.nextLine();
		employees[row][col]=number;
	}
}

if you do somthing like that you will use the first col of each row for the name, The next COL-1 elements will then become the 'number' or pay.

Anyhow this is prolly not the best way of doing it, You really should have the pay as doubles and the names as Strings.

I think what your teacher is asking you to do when he says

1. Create an instance array called employees that will hold Employee elements.

is make a class called Employee ( that would have a name and an array of pays ) and create an array of type Employee that holds the employees.

I know if thats what he means he should not say Employee elements but say Employee Objects, but hey... I am pritty certain thats he/she is getting at.

Thanks for your help, The way you laid it out makes more sense to me than what I was doing. I appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.