HELP ON errors occuring in the code

I have written the following code, in which a user has to first enter the no. of days for which he has the data available. Then he has to enter the rainfall, ETo data for those days. Then the program will calculate the required values and present the output - is irrigation required and if yes, then how much amount ?

import java.io.*;

public class calculations {

public static void main (String[] args) throws IOException

{

double rootingdepth=0.6;

double asws=125;

double sws;

double allowablecoefficient=0.45;

double mad;

double kc=0.42;

double[] netsoilwaterbalance;

double[] waterreqdforirrigation;

int i=0;

System.out.println ("Enter the days of available data");

int n=MyInput.readInt();

i=n;

double[] rainfall = new double[n];

double[] eto = new double[n];

double[] etc = new double[n];

netsoilwaterbalance = new double[n];

waterreqdforirrigation = new double [n];

sws = rootingdepth*asws;

mad = sws*allowablecoefficient;

netsoilwaterbalance[0] = mad;

for (i=0;i<n;)

{ i++;

System.out.println("Enter the rainfall values for" + i + "days");

rainfall[i] = MyInput.readDouble();

System.out.println("Enter the ETo values for" + i + "days");

eto[i] = MyInput.readDouble();

etc[i] = kc*eto[i];

}

for (i=0;i<n;)

{

i++;

netsoilwaterbalance[i] = netsoilwaterbalance[i-1] + rainfall[i] - etc[i];

System.out.println ("the amount of water in the soil on day" + i + "is" + netsoilwaterbalance[i]);

if (netsoilwaterbalance[i] <= mad)

{ System.out.println ("Irrigation is required on day" + i);

waterreqdforirrigation[i] = mad - netsoilwaterbalance[i];

System.out.println ("water reqd for irrigation on day" + i + "is" + waterreqdforirrigation[i]);

}

else

{ System.out.println ("Irrigation is not required on day" +i);

}

}

}

}

But, I am getting following error: (this error comes when I enter the rainfall data for the last day. The program stops thenafter)

" Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2

at calculations.main(calculations.java:57) "

Note: The for loop is made such that I don't have to deal with rainfall[0] (for eg)..and also to take care of "netsoilwaterbalance[i] = netsoilwaterbalance[i-1] + rainfall[i] - etc[i];" , where initially for the 1st iteration netsoilwaterbalance[1]=netsoilwaterbalance[0]+rainfall[1] should be there.