this is my code, can anyone find out why do i get error?
i don get error if i change my array column to lower than row.
import javax.swing.JOptionPane;
public class Chern_sales{
public static void main(String[] args){
double[][] sales = new double[6][7];
double[] total = new double[6];
double[] totalPerDay = new double[6];
int OFF_DAY = 0;
for(int i = 0; i<sales.length; i++){
for(int j = 0; j<sales[i].length; j++){
sales[i][j] = Double.parseDouble(JOptionPane.showInputDialog(null,"Inputing for..\nSalesperson "+(i+1)+"\nDay "+(j+1)+" Sales.") );
if(sales[i][j] == -1){
++OFF_DAY;
}
else {
//total for each sales person
total[i] += sales[i][j];
//total for each day
totalPerDay[j] += sales[i][j];
}
}
// initialize offday to zero again.
OFF_DAY = 0;
}
System.out.print("\t\t");
for(int j = 0; j<sales[0].length; j++){
System.out.print("Day "+j+"\t");
}
System.out.println("Total per week\n");
for(int i = 0; i<sales.length; i++){
System.out.print("Salesperson "+(i+1)+"\t");
for(int j = 0; j<sales[i].length; j++){
if(sales[i][j] != -1){
System.out.print("RM"+sales[i][j]+"\t");
}
else
System.out.print("OFF\t");
}
System.out.println(total[i]);
}
System.out.print("Total per day \t");
for(int i = 0; i<sales[0].length; i++){
System.out.print("RM"+totalPerDay[i]+"\t");
}
System.out.println("");
System.exit(0);
}
}