(Algebra: multiply two matrices) Write a method to multiply two matrices. The header of the method is:
public static double[][] multiplyMatrix(double[] [] a , double[][] b)
To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 × b1j + ai2 × b2j + . . . + ain × bnj·
For example, for two 3 × 3 matrices a and b, c is
where cij = ai1 × b1j + ai2 × b2j + . . . + ai3 × b3j.
Write a test program that prompts the user to enter two 3 × 3 matrices and displays their product. Here is a sample run:
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with C++: Early Objects
Concepts Of Programming Languages
Artificial Intelligence: A Modern Approach
- Q5. Write a program that reads from the user an integer matrix with 10x10, and then rotate that matrix 180° (UPSIDE DOWN) after that, calculate the sum and the average of the main diagonal. Print the matrix after the rotation and the values of the sum and the average of the main diagonal.arrow_forwardWhat do you mean by Constant array? Explain with Example .arrow_forwardcan you please make it in java.util.scannercan you please make it so i can copy and past it as well thank you in advance The product of two matrices is a calculation between two matrices. When the inner dimensions are the same, meaning that the number of columns of the first matrix A is equal to the number of rows of the second matrix B, the product of these two matrices is defined as: C[i][j] = a[i][1] * b[1][j] + a[i][2] * b[2][j] … + a[i][n] * b [n][j] (If A is an m × n matrix and B is an n × p matrix) For details on the topic, check: https://www.mathsisfun.com/algebra/matrix-multiplying.html Write a program to perform this calculation. Provide two example input arrays and calculate the output array. Note that matrix can easily be implemented in Java using 2 dimensional array. However, in Java, 2D array’s elements start at row 0 and column 0, while in mathematical definition, matrix elements start at row 1 and column 1. Consider how you will handle this…arrow_forward
- Java Script with the following: -Declare an n x n matrix of double values. -Write a method that sums all the numbers in the major diagonal using the following header:public static double sumMajorDiagonal(double[][] m)-Write a test program/main method that first prompts the user to enter the dimension n of an n x n matrix, then asks them to enter the matrix row by row (with the elements separated by spaces). -The program should then print out the sum. of the major diagonal of the matrix. -After finding the summation fill the elements of the major diagonal with the numbers 1 to n and print the new array.arrow_forwardWhat is the difference between void and NULL pointers .Give suitable examples in support of your answer.Give the differences in TABULAR form.arrow_forwardIn C++, Write a program of multiply two matrices without using functions?arrow_forward
- can you please write it in java.util.scanner form and can you make it so i can copy and past it please thank you, The product of two matrices is a calculation between two matrices. When the inner dimensions are the same, meaning that the number of columns of the first matrix A is equal to the number of rows of the second matrix B, the product of these two matrices is defined as: C[i][j] = a[i][1] * b[1][j] + a[i][2] * b[2][j] … + a[i][n] * b [n][j] (If A is an m × n matrix and B is an n × p matrix) For details on the topic, check: https://www.mathsisfun.com/algebra/matrix-multiplying.html Write a program to perform this calculation. Provide two example input arrays and calculate the output array. Note that matrix can easily be implemented in Java using 2 dimensional array. However, in Java, 2D array’s elements start at row 0 and column 0, while in mathematical definition, matrix elements start at row 1 and column 1. Consider how you will handle this difference and…arrow_forwardwhat is the value of the following expressions?arrow_forwardWrite a menu-driven program to read and display a p¥q¥r matrix. Also, find the sum, transpose, and product of the two p*q*r matricesarrow_forward
- **The solution must be using pointer ** withoutarrow_forwardIndicate true or false for the following statements: a. Every element in an array has the same type. b. The array size is fixed after an array reference variable is declared. c. The array size is fixed after it is created. d. The elements in an array must be of a primitive data typearrow_forwardhow to work? how to remove odd numbers in array?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning