/*THE OUTPUT SHOULD BE LIKE THIS:
2 4 6 8 10 - 30 //gets the sum of first column
12 14 16 18 20 - 60 //gets the sum of second column
1 2 3 4 5 - 15 //gets the sum of third column
6 5 4 3 2 - 20 //gets the sum of fourth column
125 //gets the sum of all columns
*/
//HERE IS MY CODE:
public class test
{
public static void main(String[] ar) {
int[][] num = {{2, 4, 6, 8, 10},
{12, 14, 16, 18, 20},
{1, 2, 3, 4, 5},
{6, 5, 4, 3, 2}};
int sum = 0;
for(int i=0; i<4; i++)
{
for(int j=0; j<5+1; j++)
{
System.out.print(" " + num[i][j]);
sum += num[0][j];
}
System.out.println(" " + sum);
}
}
}