There is one problem when using nextInt().
If you use it on classic user-input, it takes integer, but it left end of line in that scanner. So when you use nextLine, it finds the end of line and "skip it".
The easiest solution is to "flush it" after use:
int NUMBER_OF_EMPLOYEES = turtle.nextInt();
turtle.nextLine();
Then you mispelled the right variable, change this line :
for (int a = 0; z < (hours[0].length); a++) {
to this :
for (int a = 0; a < (hours[0].length); a++) {
and the last mistake
This line
for (int z = 0; i <= employee[0].length; z++) {
should be changed to :
for (int z = 0; z < employee[0].length; z++) {
Runnable code :
public static void main(String[] arges) {
Scanner turtle = new Scanner(System.in);
String[] calender = { "S", "M", "T", "W", "Th", "F", "S" };
System.out.println("How many Employee's do you have?: ");
int NUMBER_OF_EMPLOYEES = turtle.nextInt();
turtle.nextLine();
int [][]hours;
hours = new int[NUMBER_OF_EMPLOYEES][7];
String[][] employee = new String[NUMBER_OF_EMPLOYEES][2];
// input for Names
for (int x = 0; x < (employee.length); x++) {
System.out.println("Name of Employee " + (x + 1) + ": ");
String name = turtle.nextLine();
employee[x][1] = name;
}
// input for Hours
for (int z = 0; z < hours.length; z++) {
System.out.println("Starting from Sunday Enter the hours Employee "+ (z + 1)+ " have worked (Make sure you seperate it by spaces): ");
for (int a = 0; a < (hours[0].length); a++) {
hours[z][a] = turtle.nextInt();
}
}
// Print everything out
for (int i = 0; i < employee.length; i++) {
for (int z = 0; z < employee[0].length; z++) {
System.out.print(employee[i][z] + "-");
}
for (int f = 0; f < NUMBER_OF_EMPLOYEES; f++) {
System.out.print(" " + hours[i][f]);
}
}
// Total hours.
for (int s = 0; s < hours[0].length; s++) {
int counter = 0;
for (int d = 0; d < hours.length; d++) {
hours[d][s] += counter;
}
System.out.println("Employee " + (s + 1) + ":" + counter + " Hours");
}
}
Sample output :
How many Employee's do you have?:
1
Name of Employee 1:
libik
Starting from Sunday Enter the hours Employee 1 have worked (Make sure you seperate it by spaces):
10 20 30 40 50 60 70
null-libik- 10Employee 1:0 Hours
Employee 2:0 Hours
Employee 3:0 Hours
Employee 4:0 Hours
Employee 5:0 Hours
Employee 6:0 Hours
Employee 7:0 Hours