So far I have a method that totals the columns, but it's not exactly what I need.
I need to have the total of each row to the right of each row, and the total of each column at the bottom of each column. Something like this
1 2 3 4 = 10
3 4 5 6 = 18
4 6 8 10 < - Total
What I have now gives me the total of each column, but not under the columns.
Method
// method to add the sum of columns
public static int[] columnSum(int x[][]){
int temp[] = new int[x[0].length];
for (int i = 0; i < x[0].length; i++){
int sum = 0;
for (int j = 0; j < x.length; j++){
sum += x[j][i];
}
temp[i] = sum;
System.out.println("Index is: " + i + " Sum is: "+sum);
}
return temp;
}
}