public class Test1
{
public static void main(String[] args)
{
int[][] workHours = {
{2, 4, 3, 4, 5, 8, 8},
{7, 3, 4, 3, 3, 4, 4},
{3, 3, 4, 3, 3, 2, 2},
{9, 3, 4, 7, 3, 4, 1},
{3, 5, 4, 3, 6, 3, 8},
{3, 4, 4, 6, 3, 4, 4},
{3, 7, 4, 8, 3, 8, 4},
{6, 3, 5, 9, 2, 7, 9}
};
int[] weeklyTime = new int[workHours.length];
for(int i = 0; i < workHours.length; i++)
for(int j = 0; j < workHours[i].length; j++)
weeklyTime[i] += workHours[i][j];
show(weeklyTime);
}
public static void show(int[] weeklyTime)
{
int[] temp = new int[weeklyTime.length];
System.arraycopy(weeklyTime, 0, temp, 0, weeklyTime.length);
for(int i = 0; i < weeklyTime.length; i++)
{
int currentMaxTime = -1;
int currentMaxTimeIndex = -1;
for(int j = 0; j < weeklyTime.length; j++)
{
if(currentMaxTime < weeklyTime[j])
{
currentMaxTime = weeklyTime[j];
currentMaxTimeIndex = j;
}
}
if(currentMaxTimeIndex != -1)
{
System.out.println("Employee " + currentMaxTimeIndex + ": " + weeklyTime[currentMaxTimeIndex]);
weeklyTime[currentMaxTimeIndex] = -1;
}
}
}
}