Lab #3 The Matrix Class
The main purpose of this lab exercise is to use the Java constructs we have been studying:
- Arrays
- Control flow statements (conditionals and loops)
- Class and method creation
- Text output
We will accomplish this goal by writing an application that can add and subtract two like
matrices. A Matrix is simply a 2 dimensional array, or an array of arrays.
this text file describes the assignment
A few thoughts on the lab…
- This is another long lab and some lecture material has to be reviewed together
- I expect that I will allow time from Thursday's lecture to complete the lab.
- It helps to think of an array as a row of elements and a 2D array as having multiple rows.
- for a type such as int[][], think of int[number-of-rows][number-of-columns]
- My recommendation is to use nested for loops to traverse the elements of the matrix.
- the first, or outer-most for loop will iterate the rows
- the second, or inner-most for loop will iterate the columns (or, if you prefer, a single array)
- remember to start counting with element 0.