import java.util.Scanner;
public class Homework1 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
final int ROW;
final int COL;
int integar;
int total;
System.out.println("Total number of rows: ");
ROW = scan.nextInt();
System.out.println("Total number of colums: ");
COL = scan.nextInt();
int [][] nums = new int [ROW][COL];
for (int r = 0; r < ROW; r++){
for (int c = 0; c < COL; c++){
System.out.print("Enter a number: ");
nums [r][c] = scan.nextInt();
}
}
for (int r = 0; r < ROW; r++){
for (int c = 0; c < COL; c++){
System.out.print(nums [r][c] + " ");
}
System.out.println("");
}
for (int r = 0; r < ROW; r++){
total = 0;
for (int c = 0; c < COL; c++){
total += nums [r][c];
}
System.out.println("Sum of each row " + "is " + total);
}
}
}
Basically the assignment requires the sum of each row, which I have already and the sum of all elements of the array which I'm really stuck on for the past few hours. I know I need another for loop but really not sure how to write it