# Computing Arrays...

• January 30th, 2011, 03:34 PM
sarahmiller1980
Computing Arrays...
I'm having some real problems with the last bit of the programming. I have to use a nested loop to add the up the amounts in each row (which I did). Then, the program has to add up all of the row totals and store it for another calculation. When that's completed, I have to use two, non-nested for loops. One loop has to compute the percentage of each columns contribution to the over all total that was "stored".

Here's what I've got.
Code Java:

```public class SalesAnalysis { public static void main(String[] args) { int salesTable[][] = new int [6][5]; int column, row;   salesTable[0][0] = 750; salesTable[1][0] = 800; salesTable[2][0] = 700; salesTable[3][0] = 850; salesTable[4][0] = 900;   salesTable[0][1] = 660; salesTable[1][1] = 700; salesTable[2][1] = 600; salesTable[3][1] = 800; salesTable[4][1] = 800;   salesTable[0][2] = 910; salesTable[1][2] = 950; salesTable[2][2] = 750; salesTable[3][2] = 1000; salesTable[4][2] = 960;   salesTable[0][3] = 800; salesTable[1][3] = 900; salesTable[2][3] = 600; salesTable[3][3] = 950; salesTable[4][3] = 980;     for(row = 0; row < 5; row++) { for(column = 0; column < 4; column++) { salesTable[row][4] += salesTable[row][column]; }   System.out.println("Department " + (row + 1) + " total sales " + salesTable[row][4]); }   System.out.println(""); for(column = 0; column < 4; column++) {   for(row = 0; row < 5; row++) {salesTable[5][column] += salesTable[row][column];} System.out.println("Quarter " + (column + 1) + " total sales " + salesTable[5][column]); }   System.out.println(""); for(column = 0; column < 4; column++) {   } } }```
• January 31st, 2011, 06:50 AM
DanBrown
Re: Computing Arrays...
Quote:

I'm having some real problems with the last bit of the programming. I have to use a nested loop to add the up the amounts in each row (which I did). Then, the program has to add up all of the row totals and store it for another calculation. When that's completed, I have to use two, non-nested for loops. One loop has to compute the percentage of each columns contribution to the over all total that was "stored".

What do you want from us ?