Write the following methods in a Java program:

a) A Java method fillArray() that shall fill a 2D array from the keyboard . The method input parameters are an array A and the array size.

b) A Java method printArray() that shall print the elements of 2D array. The method input parameters are an array A.

c) A Java method multiply_ScalarMatrix() .This method shall print the result of multiplying a 2D array by a number . The method parameters are: array A and the number n.

d) A Java method multiplyMatrix() .This method shall print the result of multiplying a 2D array with another 2D array number . The method parameters are: array A and array B

Hint: To multiply 2 matrices?

Step 1: Make sure that the number of columns in the 1st one equals the number of rows in the 2nd one.

Step 2: Multiply the elements of each row of the first matrix by the elements of each column in the second matrix.

Step 3: Add the products

For details : Matrix Multiplication: How to Multiply Two Matrices Together. 1st you need to ...

------------

I have done (a) and (b) and didn't know how to do (c) and (d)

that's what i did so far:

Scanner read = new Scanner(System.in); int row = 0; int col = 0; System.out.println("insert row"); row = read.nextInt(); System.out.println("insert col"); col = read.nextInt(); int a[][] = new int[row][col]; fillArray(a, row, col); printArray(a, row, col); System.out.println("The sum is: " + sumArray(a)); } //Fill array public static void fillArray(int array[][], int a, int b) { Scanner read = new Scanner(System.in); for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { System.out.println("please insert item number [" + i + "][" + j + "]"); array[a][b] = read.nextInt(); } } } public static void printArray(int array[][], int a, int b) { for (int i=0; i<a; i++) { for (int j=0; j<b; j++) { System.out.print(array[i][j]+" "); } System.out.println(""); } } public static int sumArray(int a[][]) { int sum = 0; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[0].length; j++) { sum = sum + a[i][j]; } } return sum; } }