Question: Matrix Subtraction Objective: Write a program that can create two matrices and then subtracts them! The user first inputs the size length and width The
Matrix Subtraction
Objective:
Write a program that can create two matrices and then subtracts them!
The user first inputs the size length and width
The user then inputs the size length and width of the next matrix
Next the user populates that matrices with data
The program must check to see if the dimensions match. Matrix subtraction requires the size of both to be the same. If they are not then print Cannot subtract these! Dimension mismatch
If they do match correctly then create a new matrix and put the newly subtracted info inside of it.
Subtract each component wise, so A[1][1] +-B[1][1] = C[1][1]
Example Dialog:
Welcome to the matrix subtracting program
Please enter the length of the first matrix
2
Please enter the height of the first matrix
2
Please enter the length of the second matrix
2
Please enter the height of the second matrix
2
Please enter a value for matrix 1 space 1, 1
4
Please enter a value for matrix 1 space 1, 2
1
Please enter a value for matrix 1 space 2, 1
8
Please enter a value for matrix 1 space 2, 2
7
Please enter a value for matrix 2 space 1, 1
1
Please enter a value for matrix 2 space 1, 2
3
Please enter a value for matrix 2 space 2, 1
2
Please enter a value for matrix 2 space 2, 2
4
4 1
8 7
-
1 3
2 4
=
3 -2
6 3
DONE!
i need it by Drjava program please
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
