aspose file tools*
The moose likes Beginning Java and the fly likes Array stuff again... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array stuff again..." Watch "Array stuff again..." New topic
Author

Array stuff again...

Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Layne, Typos are good sometimes...keeps us all smiling.


) ) ) )
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Rose,

I'm still waiting for a description of what I wrote for you. It's important that YOU understand what I coded for you.

Then, lets see some:

1) Business rules (e.g. define input, step 1,2,3, etc. output, including spaces to lign up columns, etc)

2) I need you to look at this and tell me how we're going to get keyboard input.

Chatter is important sometimes, and yes, I'm guilty too, however, if you've got that much work, let's focus on the problem at hand.

Tell us a little more about the description of the problem and let's break it down. We should be able to get this done in a day, no problem.


Marcus L´┐Żubli, SCJP 1.4, CLP 5.0, SCWCD 1.4 (preparing)
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Marcus....HELPPPPPPPPPPPPPPPPP!!! OK I got this far on my java...but I'm not happy with it. I would rather input employee 1's hours Monday, Tuesday, Wednesday, and so on, instead of inputting employee 1's hours on Monday, then employee 2 on Monday and so on. And the darn period..is so far away from the day...(can you see what I mean?) Helpppppp, please....ha

Enter the hours for employee number 1 worked on Monday .
8
Enter the hours for employee number 2 worked on Monday .
9
Enter the hours for employee number 3 worked on Monday .
6
Enter the hours for employee number 1 worked on Tuesday .
5
Enter the hours for employee number 2 worked on Tuesday .
4
Enter the hours for employee number 3 worked on Tuesday .
5
Enter the hours for employee number 1 worked on Wednesday.
4
Enter the hours for employee number 2 worked on Wednesday.
5
Enter the hours for employee number 3 worked on Wednesday.
4
Enter the hours for employee number 1 worked on Thursday .
5
Enter the hours for employee number 2 worked on Thursday .
4
Enter the hours for employee number 3 worked on Thursday .
5
Enter the hours for employee number 1 worked on Friday .
4
Enter the hours for employee number 2 worked on Friday .
5
Enter the hours for employee number 3 worked on Friday .
5
Employee 1 2 3 Totals

Monday 8 9 6 23
Tuesday 5 4 5 14
Wednesday 4 5 4 13
Thursday 5 4 5 14
Friday 4 5 5 14

Total = 26 27 25
Press any key to continue . . .
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Rose, This is a very good start.

We're going to make an input method and an output method.

Let's start with input

Here's what we have to do. We have to use a nested loop. This is a loop inside a loop. The question is which loop should go inside.

Let me show you how this works..



If you use this structure for data imput, You see that the employee loop has to go on the outside, the weekday loop on the inside.

Alright, here are the additional pieces you'll need:

Arrays to hold Employees (3), Days (5) and HoursWorked (1).

Assignment: Into the code I posted, build a 3 dimensional array. Post the code.

We'll make an output loop too. This will probably have to be inverted. We'll see when we get there!
[ February 02, 2005: Message edited by: Marcus Laubli ]
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Hum? I have some loops going on...but I don't like em. Ha.

Oops, not sure if that printed out right or not....but I just don't like my loop like I have it....I want to get all of employee 1's Mon - Fri hours down first, then go on to the 2nd employee....

Shoot, shoot, I'm just not too good at this!!

[JAM -- edited to add the [CODE] and [/CODE] tags]
[ February 04, 2005: Message edited by: Joel McNary ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Rose Evans:
Oops, not sure if that printed out right or not....
Surround your pasted code with [ CODE ] ... [ /CODE ] tags. You can use the "Instant UBB Code" buttons below the "Add Reply" button.
I want to get all of employee 1's Mon - Fri hours down first, then go on to the 2nd employee....
Reread (or read ) Marcus's post. He explains exactly why your program behaves as it does. Note that when using nested loops, often the "first" one in the file is not the "first" one that you'll obvious see when running the program. If that consfused you, just read Marcu's post.
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
David, Thank you. I'll read Marcus' post. You and him are some very smart java people that's for sure!!!
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Rose,

I'll get to your post of this morning a little later today. I'm on the way out for a job interview and have to focus on that for now. I'm guessing it'll be dinner time my time before I can get to it.

I see you have two for loops.

Try to invert them like this...


That way, you hit employee 1 , do his hours, employee 2, do his hours, etc.
You know how do make a for loop, go do it! I'll be back in about 3 hours
[ February 03, 2005: Message edited by: Marcus Laubli ]
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Marcus...how'd the job interview go?!!! I hope you got it. I left work early today, so I didn't get to do my java....had an appointment out of town....now I have the home stuff to take care of...kids, house etc...

Hopefully, I can work on it soon. Thanks so much for all your help!!
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Got there and froze. Fell flat on my face.
[ February 03, 2005: Message edited by: Marcus Laubli ]
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
Oh no...I'm sorry to hear that. I'm sure they knew you were just nervous. I hate interviews.....ewwwwwwwwwwwwwwww. I've got to do a mock interview at school, where we all have to dress up in business clothes, and be taped while we are interviewed and then we have to watch the tape back while they give us pointers of what we did right and wrong. I dread that for sure. I know I'll bomb on that. I'm no good at interviews for sure.
I'm off work today...so I think I'll go back to bed for a while. It's nice to sleep in sometimes. Talk to you soon.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array stuff again...
 
Similar Threads
what results byte code in java
Creating SingleTON without static variables
Enum Problem
retrieve enumeration datatype into jsp
How to define constants for several classes?