diff --git a/src/main/java/Unit8/U8_L1_Activity_One.java b/src/main/java/Unit8/U8_L1_Activity_One.java new file mode 100644 index 0000000..0403d27 --- /dev/null +++ b/src/main/java/Unit8/U8_L1_Activity_One.java @@ -0,0 +1,16 @@ +package Unit8; + +// Have to get rid of package statement + +public class U8_L1_Activity_One { + + public static int sumOfDiag(int[][] arr) { + int sum = 0; + for (int i = 0; i < arr.length && i < arr[i].length; i++) { + sum += arr[i][i]; + } + + return sum; + } + +} diff --git a/src/main/java/Unit8/U8_L1_Activity_Two.java b/src/main/java/Unit8/U8_L1_Activity_Two.java new file mode 100644 index 0000000..f400ff6 --- /dev/null +++ b/src/main/java/Unit8/U8_L1_Activity_Two.java @@ -0,0 +1,18 @@ +package Unit8; + +// Have to get rid of package statement + +public class U8_L1_Activity_Two { + + public static int[][] productTable(int rows, int cols) { + int[][] table = new int[rows][cols]; + + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + table[i][j] = i * j; + } + } + + return table; + } +}