wood burning stoves 2.0*
The moose likes Java in General and the fly likes array[][] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "array[][]" Watch "array[][]" New topic
Author

array[][]

John Paul Mr
Greenhorn

Joined: Mar 04, 2003
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

Joined: Jan 07, 2007
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


Be Objectively Oriented.Explore the power of OOPs.
My Blog, Eclipse EMF Query committer.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37936
    
  22
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

Joined: Mar 04, 2003
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

Joined: Jan 09, 2008
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 ...


BEE MBA PMP SCJP-6
John Paul Mr
Greenhorn

Joined: Mar 04, 2003
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

Joined: Jan 09, 2008
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 ... ...
 
 
subject: array[][]
 
Similar Threads
summing each row in a 2-dimensional array
Two dimensional array total and sort
Array stuff again...
Something i'm extremely confused on
Sorting arrays while retaining original index