Lab 17

Matrix Subtraction

 

Objective:

 

Write a program that can create two matrices and then subtracts them!

 

 

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!

 

Lab Report Questions:

  1. Draw a flow chart of the solution and include that in the proposed solution section
  2. Is it possible to have “ragged” arrays in Java?

 

Finally:

Upload the .java file to the dropbox