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

Write a program that can create two matrices and then it multiplies them! In Jav

ID: 3762029 • Letter: W

Question

Write a program that can create two matrices and then it multiplies them! In Java

The user first inputs the size length and width

Next the user populates that matrix with data

The user then inputs the size length and width of the next matrix

Once again they populate it

Next the program must check to see if the dimensions match

A n-by-m matrix can only be multiplied by a m-by-l matrix where n, m, and l correspond to the sizes of the matrices.

If they do match correctly then create a new matrix and put the newly multiplied info inside of it.

Multiply the individual numbers of the first matrix’s columns by the individual number of the other matrix’s row and add those together.

The matrix size when multiplying a n-by-m by a m-by-l will result in a n-by-l matrix

Example Dialog:

Welcome to the matrix multiplier program

Please enter the length of the first matrix

1

Please enter the height of the first matrix

3

Please enter the length of the second matrix

3

Please enter the height of the second matrix

3

Please enter a value for matrix 1 space 1, 1

3

Please enter a value for matrix 1 space 1, 2

1

Please enter a value for matrix 1 space 1, 3

4

Please enter a value for matrix 2 space 1, 1

1

Please enter a value for matrix 2 space 1, 2

3

Please enter a value for matrix 2 space 1, 3

8

Please enter a value for matrix 2 space 2, 1

2

Please enter a value for matrix 2 space 2, 2

4

Please enter a value for matrix 2 space 2, 3

6

Please enter a value for matrix 2 space 3, 1

8

Please enter a value for matrix 2 space 3, 2

0

Please enter a value for matrix 2 space 3, 3

9

3

1

4

X

1 3 8

2 4 6

8 0 9

=

37 13 66

DONE!

Explanation / Answer

import java.util.Scanner; class MatrixMultiplication { public static void main(String args[]) { int m, n, p, q, sum = 0, c, d, k; Scanner in = new Scanner(System.in); System.out.println("Enter the number of rows and columns of first matrix"); m = in.nextInt(); n = in.nextInt(); int first[][] = new int[m][n]; System.out.println("Enter the elements of first matrix");//input first matrix here for ( c = 0 ; c
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