![Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package](https://www.bartleby.com/isbn_cover_images/9780134694511/9780134694511_largeCoverImage.gif)
(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:
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 8 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
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
- (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 + g + ain × bnj. For example, for two 3 × 3 matrices a and b, c is a11 a12 a13 a21 a22 a23 a31 a32 a33 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.arrow_forward(Algebra: add two matrices) Write a method to add two matrices. The header of the method is as follows: public static double[][] addMatrix(double[][] a, double[][] b) In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements. Let c be the resulting matrix. Each element cij is aij + bij. For example, for two 3 x 3 matrices a and b, c is b11 b12 b13 9.Eミ9 (a11 + b11 a12+ b12 a13 + b13 a21 + b21 a2 + b22 an + b3 |a31+ b31 a32 + b32 a33 + b33 a11 a12 a13 a21 a22 a23 + b21 b2 bz3 a31 a32 a33 b31 b32 b33, Write a test program that prompts the user to enter two 3 x 3 matrices and displays their sum. Sample Run for Exercise08_05.java Enter input data for the program (Sample data provided below. You may modify it.) 12 3 4 5 6 7 8 9 e 2 4 1 4.5 2.2 1.1 4.3 5.2 Show the Sample Output Using the Preceeding Input Reset Execution Result: JDK8>java Exercise08_05 Enter matrixl: 1 23 4 5 6 7 8 9 Enter matrix2: 0 2 4 1 4.5 2.2 1.1 4.3 5.2 The…arrow_forward(Algebra: add two matrices) Write a method to add two matrices. The header of the method is as follows: public static double[][] addMatrix(double[][] a, double[][] b) In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements. Let c be the resulting matrix. Each element cij is aij + bij. For example, for two 2 * 2 matrices a and b, c is Write a test program that prompts the user to enter two 2 * 2 matrices and displays their sum. Here is a sample run: Ps: pls do the exact output thanks!arrow_forward
- (Java) Suppose we have a 2D array of integers called a matrix. Write a code to initialize the array matrix with random values between 0-99. Please use a method instead of tryarrow_forward(Algebra: add two matrices) Write a method to add two matrices. The header of the method is as follows: public static double[][] addMatrix(double[][] a, double[][] b) In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements. Let c be the resulting matrix. Each element cij is aij + bij. For example, for two 2 * 2 matrices a and b, c is Write a test program that prompts the user to enter two 2 * 2 matrices and displays their sum.arrow_forward(Maximum element in an array) Implement the following method that returns the maximum element in an array . public static > E max (E[] list) Write a test program that prompts the user to enter 10 integers, invokes this method to find the max.arrow_forward
- (Java) Suppose we have a 2D array of integers called matrix. Write a code to initialize the array matrix with random values between 0-99.arrow_forward(Using Java in eclipse) Suppose we have to declare a two dimensional array called matrix with each dimension having some length. Write a message to initialize this array with random values between zero and 99. Hint: set each individual element of the right to random valuearrow_forward(Algebra: add two matrices) Write a method to add two matrices. The header ofthe method is as follows:public static double[][] addMatrix(double[][] a, double[][] b)In order to be added, the two matrices must have the same dimensions and the same or compatible types of elements.in javaarrow_forward
- (Exhaustive Search: The Assignment Problem) A magic square of order n is an arrangement of the numbers from 1 to n² in an n-by-n matrix, with each number occurring exactly once, so that each row, each column, and each main diagonal has the same sum. The example of magic squares of order 3 and order 4 are: [7 12 1 14] 2 13 8 11 16 3 10 5 9 6 15 4 [4 9 21 357 [8 1 6] Design and implement an exhaustive search algorithm for generating all magic squares of order n. 1. Show your code. 2. Show the output for n=7 3. What is the sum of each row? n(n²+1) You can Hint: The sum of each row, column, or diagonal is equal to 2 generate integers from 1 to n² and then use exhaustive search to find all n combinations in rows such that the sum of all rows, columns, and diagonals is n(n²+1) 2arrow_forwardWrite a menu driven C++ program that should perform following operation on matrices using 2D arrays. (Use OOP) The program will first take inputs for both matrices from the user then perform following operations on them: Add() This method will add two matrices. Subtract() This method will subtract two matrices. AddScalar() This method will add scalar to a matrix by asking user in which matrix to add. SubtractScalar() This method will subtract a scalar from a matrix by asking user in which matrix to add. Dont use pointers please use counters only.. Thank you very much.arrow_forward(Java in Eclipse) Write code that finds the sum of two matrices. Use the following method header public static int[][] addMatrix(int[][] a, int[][] b) The rules for adding two matrices are:1. both matrices should have the exact same dimensions (i.e. height and width) – you need to check for this rule in your program.2. both matrices should have elements that have compatible types – you don’t have to add extra code to check this rule in your method as it will only accept int arrays included is a test class and a sample runarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)