• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

array[][]

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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



 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 80123
416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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>
 
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ... ...
 
Quick! Before anybody notices! Cover it up with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic