Need help creating code for this assignment if you look at the picture and withi
ID: 3814969 • 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.
public class DotProduct
{
public static void main(String[] args)
{
// Insert your Identification String as a comment below.
//
// create the array A exactly as shown
int[][] A = { {10,55,4,89,39} , {45,9,49,98,23} , {4,8,90,23,9} , {8,32,80,2,31} };
// create the array B exactly as shown
int[][] B = ___________________________________________________________________;
// prepare the product array C, currently empty (filled with 0's)
int[][] C = __________________;
// compute the dot product of A's row 2, and B's column 1
int sum = ___________;
for (int i=__________; i <= __________; __________)
{
sum = sum + A[____][____]*B[____][____];
}
// set the value of C[2][1]
C[___][___] = ____________;
System.out.println(_________);
} // end main
} // end class
Explanation / Answer
HI, Please find my implementation.
public class DotProduct
{
public static void main(String[] args)
{
// Insert your Identification String as a comment below.
//
// create the array A exactly as shown
int[][] A = { {10,55,4,89,39} , {45,9,49,98,23} , {4,8,90,23,9} , {8,32,80,2,31} };
// create the array B exactly as shown
int[][] B = { {40,1,16} , {90,3,7} , {9,2,22} , {44,35,60}, {18,67,21} };
// prepare the product array C, currently empty (filled with 0's)
int[][] C = new int[4][3];
// compute the dot product of A's row 2, and B's column 1
int sum = 0;
for (int i=0; i < 5; i++)
{
sum = sum + A[2][i]*B[i][1];
}
// set the value of C[2][1]
C[2][1] = sum;
System.out.println(sum);
} // end main
} // end class
/*
Output: 1616
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.