Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Difference of two matrices.java Write a program that accepts two 3 x 3 matrices and invokes a method to subtract them together. The formula for

Difference of two matrices.java

Write a program that accepts two 3 x 3 matrices and invokes a method to subtract them together. The formula for subtracting two matrices is shown below:

image text in transcribed

You will need:

1.) A scanner object to read the values that fill the arrays

2.) 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 difference of the values from the first two matrices

3.) A method that subtracts the two matrices using the formula above. The method should accept the first and second matrices as parameters (i.e. a and b,) and return an array. (The array should be returned to the matrix in part c.)

4.) Comments where necessary.

The output should be as shown below:

Enter matrix1: 29 28 27 26 25 24 23 22 21

Enter matrix2: 1 2 3 4 5 6 7 8 9

The difference of the matrices is:

29.0 28.0 27.0

26.0 25.0 24.0

23.0 22.0 21.0

-

1.0 2.0 3.0

4.0 5.0 6.0

7.0 8.0 9.0

=

28.0 26.0 24.0

22.0 20.0 18.0

16.0 14.0 12.0

6 11 12 13 11 12 13 21 22 23-21 22 23 21-D 21 a 22-D 22 a 23-D 23 31 3233 131 32 32 33-3

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

More Books

Students also viewed these Databases questions