so I have written the code to a program that should initialize a data set of totals from different locations and display them as such. for some reason I keep getting a run time error on the first for-loop and can't figure out why. can someone please help me figure out what I'm doing wrong?
public class Sales {
private static String[] months;
private static String[] cities;
private static int[] citySum;
private static int[] monthlySum;
private static int[][] sales;
private static int col;
private static int row;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
calCityTotal();
calMonthlyTotal();
displayTable();
}
public Sales() {
months = new String[] {"January","Febuary","March","April",
"May","June"};
cities = new String[] {"Chilliwack","Kamloops","Kelowna",
"NanaimoSurrey","Vancouver","Victoria"};
sales = new int[][] {{400,500,500,600,500,600},
{600,800,800,800,900,900},
{700,700,700,900,900,1000},
{500,600,700,800,700,700},
{900,900,900,1000,1100,1100}};
citySum = new int[sales.length];
monthlySum = new int[sales[0].length];
}
public static void calCityTotal() {
for (row = 0; row < sales.length; row++){
for (col = 0; col < sales[0].length; col++){
citySum[col] += sales[row][col];
}
}
}
public static void calMonthlyTotal() {
for (row = 0; row < sales.length; row++){
for (col = 0; col < sales[0].length; col++){
monthlySum[row] += sales[row][col];
}
}
}