Computer Science Canada Organizing this... |
Author: | .:hacker:. [ Mon May 16, 2005 6:40 pm ] | ||
Post subject: | Organizing this... | ||
Hi, it's me again and I have a couple quick questions . Let's say I have number data on an editpad/notepad file, how would I organize that into a table (with text borders) using a 2-D array? I've got the thing to compile and all, but it only prints out one line:
Or... do I need to change it into an output instead of an input, i'm not sure. I wrote the file like this but it only prints out the months: Month North East South West Jan. Feb. Mar. (numbers go here) Apr. May Jun. Also, once I've got the file in there how would I calculate averages and other related things this way...? I'm not completely sure. |
Author: | wtd [ Mon May 16, 2005 7:51 pm ] | ||||||||
Post subject: | |||||||||
Let's try some decently formatted code for starters.
Now...
You're trying to set everything equal to zero. Yet, you're just assigning 0 to precipitation[5][7] over and over. Your next problem: that doesn't exist. When you declare a 2D array with: [5][7] that means it is five seven element arrays. They start at zer, though, so the highest you can go is 4 and 6.
Variables in Java always begin with a lowercase letter.
This should go in a "finally" block. |
Author: | .:hacker:. [ Tue May 17, 2005 6:25 am ] |
Post subject: | ... |
So... if I started at one, woud be able to go higher? Heh heh... sorry if this sounds like a stupid question. |
Author: | wtd [ Tue May 17, 2005 11:12 am ] |
Post subject: | Re: ... |
.:hacker:. wrote: So... if I started at one, woud be able to go higher?
Heh heh... sorry if this sounds like a stupid question. All arras in Java have a starting index of zero. Can't change it. |