import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); double[][] matrix = new double[4][4]; System.out.print("Enter a 4-by-4 matrix row by row: "); for(int i = 0; i < 4; i++) for(int j = 0; j < 4; j++) matrix[i][j] = input.nextDouble(); input.close(); System.out.println("Sum of the matrix is " + sumMatrix(matrix)); } public static double sumMatrix(double[][] m) { double sum = 0; for(double[] i: m) for(double j: i) sum += j; return sum; } }