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

Need help completing assignment!! Attached instructions public class MoreProduct

ID: 3602209 • Letter: N

Question

Need help completing assignment!! Attached instructions

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

5.7 Lab5d Due Oct26 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: systemaiii .out.printf("8 3d",); 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 4x5 matrix A, a 5x 3 matrix B, and a resulting product 4 x 3 matrix C. Matrix A Matrix B 0 1 2 3 4 10 55 489 39 0 40 45 g 49 98 23 1903 24890 239 29 38 3280 2031 3 44 35 60 67 21 Product Matrix C 100045911 6792 7777 5141 8224 2864 1616 3669 4566 2411 2883 Note that C21is 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. LAB 5.7.1: Lab5d Due Oct-26 ACTIVITY 0/13

Explanation / Answer

MoreProducts.java

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 <p; j++)
{
C[i][j] = 0;
for (int k=0; k <4; 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 <5;i++) {
for (int j=0; j <4; 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< 4; i++) {
for (int j=0; j <2; 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< 5; i++) {
for (int j=0; j < 2; j++)
System.out.printf("%5d",C[i][j]);
System.out.println();
}
  
} // end main
} // end class

_________________

Output:

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

________________Thank YOu

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