Advertisement
Vasilena

ProgrammingExercize150221.1

Feb 15th, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Programming150221i2 {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.             int[][] mat ={{3,4,8}, {9,5,2}, {1,6,0}};
  7.             int sum = 0;
  8.             for (int i = 0; i < mat.length; i++) {
  9.                 int[] currentRow = mat[i];
  10.                 for (int j = 0; j < currentRow.length; j++) {
  11.                     sum += currentRow[j];
  12.                 }
  13.             }
  14.         System.out.println("The sum of the matrix is = " + sum);
  15.     }
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement