Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

here is my code public class J1_08 { static void toPrintoutMatrix(String[] args) { int rowSize = 0, colSize

imageimage

here is my code

 

public class J1_08 {
    static void toPrintoutMatrix(String[] args) {

        int rowSize = 0, colSize = 0;
        int Multi[][] = new int[0][];

        for (int i = 0; i < rowSize; i++) {
            for (int j = 0; j < colSize; j++) {
                System.out.print(Multi[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void multiplyingTheMatrix(int firstRow, int firstColumn, int A[][], int secondRow, int secondColumn, int B[][]) {
        int a, b, c;

        System.out.println("The Matrix A is: ");
        toPrintoutMatrix(A, firstRow, firstColumn);

        System.out.println("The Matrix for B is: ");
        toPrintoutMatrix(B, secondRow, secondColumn);

        if (secondRow != firstColumn) {
            System.out.println("Can't be multiplied ");
            return;
        }

        int C[][] = new int[firstRow][secondColumn];

        for (a = 0; a < firstRow; a++) {
            for (b = 0; b < secondColumn; b++) {
                for (c = 0; c < secondRow; c++) {
                    C[a][b] += A[a][c] * B[b][c];
                }

            }
        }
        public static void main (String[] args){
            int firstRow = 5, firstColumn = 3, secondRow = 3, secondColumn = 5;

            int A[][] = {{1, 2, 3},
                    {4, 5, 6},
                    {7, 8, 9},
                    {0, 1, 2},
                    {3, 4, 5}};                         /*matrix for A*/

            int B[][] = {{1, 2, 3, 4},
                    {5, 6, 7, 8},
                    {9, 0, 1, 2}};                      /*matrix for B*/
        }
        System.out.println();
    }


}


Matrix multiplication: A X B= C where A, B are 5 x 3, 3 x 4 matrix respectively 1. Create two random 1digit-integer matrices (2-dimensional arrays) A and B 2. Perform matrix multiplication and print out the result matrix *Tip: Programming Exercise 8.6 (Algebra: multiply two matrices) in the Liang textbook and the links: https://www.mathsisfun.com/algebra/matrix-multiplying.html Khan Academy: https://bit.ly/2Ydetec 3. Verify your algorithm by checking the followings: A. the number of columns of the matrix A is equal to the number of rows in matrix B. B. the size of the result matrix (C) is 5 X 4. C. c11 = a11 x b11+ a12 x b21+ a13 x b31 (a,b,c are elements of A,B and C respectively) c54a51 x b14 + a52 x b24 + a53 x b34 D. check your result with https://onlinemschool.com/math/assistance/matrix/multiply/ and submit the screenshot like this: The first matrix: 4 5 6 A = 7 8 9 0 1 2 4 5 The second matrix: 1 2 3 B = 5 6 7 8 9 0 1 2 A-B You can input only integer numbers, decimals or fractions in this online calculator (-2.4, 57,...). More in-depth information read at these rules. CONTINUE > Solution: 123 456 38 14 20 26 C=AB= 789 012 1 2 3 4 5678 9012 83 38 53 68 128 62 86 110 345 23 69 68 30 42 12 54 The components of the matrix C is calculated as: C11 11 11 +12 b21+013 b311-1+2-5+3-9=1+10+27=38 C12 11 12 12 b22+ a13 b32 1-2+2 6+3-0-2+12+0-14 + C13 11 13 012 b23+a13-b33-1-3+2-7+3-1-3+14+3=20 - Click Continue Answer 20 Questions Get your IQ

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

Students also viewed these Programming questions

Question

Describe the object-oriented database concept.

Answered: 1 week ago

Question

How to Construct a Stem and Leaf Plot

Answered: 1 week ago