Posted: 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:
code:
public class Assign5
{
public static void ArrayOne (String [] args) throws IOException
{
int [][] precipitation = new int [5][7];
for (int i = 0; i < 5; i++)
{
for (int j = 0; j<3; j++)
{
precipitation [5][7] = 0;
}
}
}
// The main method
public static void main (String [] args) throws IOException
{
// variables for the averages
int averAll;
int averNorth;
int averApril;
int highJune;
int lowest;
int secondlow;
// The main method publicstaticvoid main (String[] args)throwsIOException { // variables for the averages int averAll;
int averNorth;
int averApril;
int highJune;
int lowest;
int secondlow;
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.