This week's book giveaways are in the Refactoring and Agile forums.We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!

# array[][]

John Paul Mr
Greenhorn
Posts: 3
Suppose the weekly hours for all employees are stored in a two-dimensional array. Each row records an employee’s seven-day work hours with seven columns. For example, the following array stores the works hours for eight employees. Write a program that displays employees and their total hours in decreasing of the total hours.[/b]

Su M T W H F Sa
Employee 0 2 4 3 4 5 8 8
Employee 1 7 3 4 3 3 4 4
Employee 2 3 3 4 3 3 2 2
Employee 3 9 3 4 7 3 4 1
Employee 4 3 5 4 3 6 3 8
Employee 5 3 4 4 6 3 4 4
Employee 6 3 7 4 8 3 8 4
Employee 7 6 3 5 9 2 7 9

saurav sarkar
Ranch Hand
Posts: 180
It would be good if you try to write a program first and then
publish your findings and any questions if you have.
We would be able to extend our help in a better way.

cheers,
Saurav

Campbell Ritchie
Sheriff
Posts: 48396
56
Welcome to the Ranch
saurav sarkar
[pedantic mode]No, you do not have a 2-d array. There is no such thing. You have an array of arrays.[/pedantic mode] And saurav sarkar is correct; you need to show us what you have achieved, and then we can help you.

John Paul Mr
Greenhorn
Posts: 3
John Paul Mr wrote:Suppose the weekly hours for all employees are stored in a two-dimensional array. Each row records an employee’s seven-day work hours with seven columns. For example, the following array stores the works hours for eight employees. Write a program that displays employees and their total hours in decreasing of the total hours.[/b]

Su M T W H F Sa
Employee 0 2 4 3 4 5 8 8
Employee 1 7 3 4 3 3 4 4
Employee 2 3 3 4 3 3 2 2
Employee 3 9 3 4 7 3 4 1
Employee 4 3 5 4 3 6 3 8
Employee 5 3 4 4 6 3 4 4
Employee 6 3 7 4 8 3 8 4
Employee 7 6 3 5 9 2 7 9

i have done with....

public class NewClass8 {
public static void main (String[]args){

System.out.println (" "+"\t\t"+"sun"+"\t"+"mon"+"\t"+"tue"+"\t"+"wed"+"\t"+"thu"+"\t"+"fri"+"\t"+"sat");

int [][]array = {
{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}};

for(int i=0; i<array.length; i++){
System.out.println("Employee"+i);

}
}
}

but i dont know how to put the number inside>

Jim Hoglund
Ranch Hand
Posts: 525
Java does not support multi-dimension arrays directly. Rather, you should
create Employee objects where each Employee has an Hours[array] with an
entry for each day. The Employees could then be stored in an Employee[array].
Working with the data this way makes more sense because it's in the language
of the problem. I hope this helps?
Jim ...

John Paul Mr
Greenhorn
Posts: 3
public class NewClass8 {
public static void main (String[]args){

System.out.println (" "+"\t\t"+"sun"+"\t"+"mon"+"\t"+"tue"+"\t"+"wed"+"\t"+"thu"+"\t"+"fri"+"\t"+"sat");

int [][]array = {
{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}};

for(int i=0; i<array.length; i++){
System.out.print("Employee"+i);
for(int j=0; j><array.length; j++){
System.out.print(array[i][j]);
}
}
System.out.println();
}
}>

Jim Hoglund
Ranch Hand
Posts: 525
Paul : Is this an assignment where you are asked to
manipulate arrays? If so, it's an odd thing to focus
on in a Java class. Anyway, what is your question?
Jim ... ...