Getting Run time (NZEC )exception...pls help

import java.util.*;
class Days_In_Month
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String ar[]={“mon”,“tues”,“wed”,“thurs”,“fri”,“sat”,“sun”};
System.out.println(“Enter no. of testcases:”);
String t=sc.nextLine();
int T=Integer.valueOf(t);
if(T<1||T>1000)
{
System.out.print(“INVALID INPUT”);
System.exit(0);
}
for(int ik=1;ik<=T;ik++)
{
int a[]={4,4,4,4,4,4,4};
System.out.println(“Enter W:”);
String w=sc.nextLine();
int W=Integer.valueOf(w);
if(W<28||W>31)
{
System.out.print(“INVALID INPUT”);
System.exit(0);
}
System.out.println(“Enter S:”);
String s=sc.nextLine();
int ed=W-28;
int i,index=0;
for(i=0;i<7;i++)
{
if(s.equals(ar[i]))
index=i;
}
for(i=index;i<(index+ed);i++)
{
a[i]++;
}
for(i=0;i<7;i++)
{
System.out.print(a[i]+" ");
}
ed=0;
System.out.println();
}
}
}

If the value of W = 31
value of s = “sun”
Then ed = 31 - 28 = 3
index = 6
So running a loop from 6 to 9 will give you index out of bound exception because size of array a is 7.
This is the case where you are getting run time error, if I am not wrong.

Please post the link of the solution or post it in code tag