Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help creating code for this assignment if you look at the picture and withi

ID: 3816034 • Letter: N

Question

Need help creating code for this assignment if you look at the picture and within the code will have tasks and will show what to do. The first picture is the assignment for this code, the second picture is just to help you understand this assignment

public class MoreProducts
{
public static void main(String[] args)
{

// create the array A exactly as shown:
// 19 18 22 23
// 16 25 2 67
// 26 3 80 99
// 80 80 80 80
// 66 82 13 26
int[][] A = {};

// create the array B exactly as shown:
// 89 10
// 22 32
// 7 59
// 44 1
int[][] B = {};

// prepare the product array C, currently empty (filled with 0's)
int[][] C = new int[A.length][B[0].length];
  
  
int m = ____________; // number of rows in Matrix A
int n = ____________; // number of columns in Matrix A, which must equal number of rows in Matrix B
int p = ____________; // number of columns in Matrix B

  
// compute the dot product of A and B, store the results in C
for (int i=____; i < ____; i++)
{
for (int j=____; j < ____; j++)
{
C[i][j] = 0;
for (int k=____; k < ____; k++)
// sum the values for C
C[i][j] += A[____][____]*B[____][____];
}

}

// print A
System.out.println("Matrix A ");
for (int i=____; i <____; ____) {
for (int j=____; j < ____; ____)
System.out.printf("%5d",A[____][____]);
System.out.println();
}
System.out.println();
// print B
System.out.println("Matrix B ");
for (int i=____; i< ____; ____) {
for (int j=____; j <____; ____)
System.out.printf("%5d",B[____][____]);
System.out.println();
}
System.out.println();
// print C
System.out.println("Matrix C ");
for (int i=____; i< ____; ____) {
for (int j=____; j < ____; ____)
System.out.printf("%5d",C[____][____j]);
System.out.println();
}

  
} // end main
} // end class

E 5.15 Lab5d Due 11-Apr-17 Objectives Solve a math problem using nested for loops and two-dimensional arrays Print a table-formatted two-dimensional array Background Read Lab5c for a description of the dot product of two matrices. Assignment Write a Java program that computes the dot product of two matrices and stores the values in a third matrix Print the result in tabular form. For example, to print matrix A, the print statement inside the nested for loops is: System.out.printf ("B3d A[i] [j]) Finding the pattern Multiplying matrices works when the matrices have dimensions m n and n p so that the product is a m p matrix. The example below has a 4 x 5 matrix A, a 5 x 3 matrix B, and a resulting product 4 x 3 matrix C. Matrix A Matrix B 0 1 2 3 4 1 2 0 10 55 4 89 39 0 40 1 16 1 45 9 49 98 23 1 90 3 7 2 4 8 90 23 9 2 2 22 8 32 80 20 31 3 44 35 60 18 67 21 Product Matrix C 10004 5911 6792 7777 5141 8224 2864 1616 3669 4566 2411 2883 Note that Cl2 1 is 1616, as we calculated in Lab5b. The careful student will work out the solution by hand before looking at the outlined program you are pick two small matrices with easy to compute values and figure out the expected values. S/He will also map out which indexes in A and in B give the correct product. The solution, since we have three dimensions (m, n, and p), we will need 3 nested loops to solve this problem

Explanation / Answer

Hi, Please find my implementation.

Please let me know in case of any issue.

public class MoreProducts

{

   public static void main(String[] args)

   {

       // create the array A exactly as shown:

       // 19 18 22 23

       // 16 25 2 67

       // 26 3 80 99

       // 80 80 80 80

       // 66 82 13 26

       int[][] A = {{19, 18, 22, 23}, {16, 25, 2, 67}, {26, 3, 80, 99}, {80, 80, 80, 80},{66, 82, 13, 26}};

       // create the array B exactly as shown:

       // 89 10

       // 22 32

       // 7 59

       // 44 1

       int[][] B = {{89, 10}, {22, 32},{7, 59},{44, 1}};

       // prepare the product array C, currently empty (filled with 0's)

       int[][] C = new int[A.length][B[0].length];

       int m = 5; // number of rows in Matrix A

       int n = 4; // number of columns in Matrix A, which must equal number of rows in Matrix B

       int p = 2; // number of columns in Matrix B

       // compute the dot product of A and B, store the results in C

       for (int i=0; i <m; i++)

       {

           for (int j=0; j < 2; j++)

           {

               C[i][j] = 0;

               for (int k=0; k < n; k++)

                   // sum the values for C

                   C[i][j] += A[i][k]*B[k][j];

           }

       }

       // print A

       System.out.println("Matrix A ");

       for (int i=0; i <m; i++) {

           for (int j=0; j <n; j++)

               System.out.printf("%5d",A[i][j]);

           System.out.println();

       }

       System.out.println();

       // print B

       System.out.println("Matrix B ");

       for (int i=0; i<n; i++) {

           for (int j=0; j <p; j++)

               System.out.printf("%5d",B[i][j]);

           System.out.println();

       }

       System.out.println();

       // print C

       System.out.println("Matrix C ");

       for (int i=0; i<m; i++) {

           for (int j=0; j <p; j++)

               System.out.printf("%5d",C[i][j]);

           System.out.println();

       }

   } // end main

} // end class

/*

Sample run:

Matrix A

   19 18 22 23

   16 25 2 67

   26 3 80 99

   80 80 80 80

   66 82 13 26

Matrix B

   89 10

   22 32

7 59

   44 1

Matrix C

3253 2087

4936 1145

7296 5175

12960 8160

8913 4077

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote