Using Java Modify the program 1 to compute the multiplication of two vectors with the sizes mx1 and 1xn. The result is a matrix mxn computed as follows: the element on the position r and c in the product will be equal with m1[r][0]*m2[0][c].
Using Java
Modify the program 1 to compute the multiplication of two
1. Define the two input vectors, m1 (mx1) and m2 (1xn).
2. Determine the dimensions of the result matrix:
- Let m be the number of rows in vector m1.
- Let n be the number of columns in vector m2 (length of m2[0]).
3. Initialize a result matrix of size mxn.
4. Use nested loops to perform the vector multiplication and fill the result matrix:
- For each row r from 0 to m-1:
For each column c from 0 to n-1:
a. Calculate the element at position (r, c) in the result matrix as m1[r][0] * m2[0][c].
b. Store this value in the result matrix at result[r][c].
5. Display the result matrix by iterating through it:
- For each row r from 0 to m-1:
For each column c from 0 to n-1:
a. Print the element at result[r][c] followed by a space.
6. Print a newline character to move to the next row.
Step by step
Solved in 4 steps with 2 images









