Question: Using jGRASP I need the code to run this program please Sum of two matrices Write a program that accepts two 3 x 3 matrices
Using jGRASP I need the code to run this program please
Sum of two matrices
Write a program that accepts two 3 x 3 matrices and invokes a method to add them together. The formula for adding two matrices is shown below:
You will need:
A scanner object to read the values that fill the arrays
Three 2-dimensional arrays:
One to store the values in the first 3x3 matrix
One to store the values in the second 3x3 matrix
One to store the sum of the values from the first two matrices
A method that adds the two matrices using the formula above
Comments where necessary
A sample of the output is shown below:
Enter matrix1: 1 2 3 4 5 6 7 8 9 Enter matrix2: 1 2 3 4 5 6 7 8 9 The addition of the matrices is 1.0 2.0 3.0 1.0 2.0 3.0 2.0 4.0 6.0 4.0 5.0 6.0 + 4.0 5.0 6.0 = 8.0 10.0 12.0 7.0 8.0 9.0 7.0 8.0 9.0 14.0 16.0 18.0
Tip: You may prefer to print the results out this way instead:
Enter matrix1: 1 2 3 4 5 6 7 8 9 Enter matrix2: 1 2 3 4 5 6 7 8 9 The addition of the matrices is
1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 +
1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
=
2.0 4.0 6.0
8.0 10.0 12.0
14.0 16.0 18.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
