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…

  1. This is another long lab and some lecture material has to be reviewed together
  2. I expect that I will allow time from Thursday's lecture to complete the lab.
  3. It helps to think of an array as a row of elements and a 2D array as having multiple rows.
  4. for a type such as int[][], think of int[number-of-rows][number-of-columns]
  5. My recommendation is to use nested for loops to traverse the elements of the matrix.
    1. the first, or outer-most for loop will iterate the rows
    2. the second, or inner-most for loop will iterate the columns (or, if you prefer, a single array)
    3. remember to start counting with element 0.