How to write a program to calculate and display sum in two dimensional array?
I have a college tutorial question that required me to write a program which need to calculate and display the sum of each column of a two dimensional array. For example, in the following array
2 6 -1 5
8 2 7 -5
1 0 4 4
the method shoudl display the following
The sum of column 0 is 11
The sum of column 1 is 8
The sum of column 2 is 10
The sum of column 3 is 4
Assume that in the calling program the array A is declared as float A[MAXROW][MAXCOL]; where MAXROW and MAXCOL are global int constants.
The method should have a two dimensional array as its only parameter and shold not return any values.
I have roughly wrote something on a paper, but i jst dun get the idea how to link all the tings 2gether, can anyone pls help me of this?
public class array
public static final MAXROW{
public static final MAXCOL{
public void calculate Sum(){
float A[MAXROW][MAXCOL];
for (int i = 0; i<MAXROW.length; i++)
{
for (int j = 0; j<MAXCOL.length;j++)
{
(I don't have idea in tis part)
}
}
i knw my code is poor and not completed, but im in the progress of learning, im using netbean 6.9.1, pls help me out ..thx