Skip to content

Commit

Permalink
feat(8.1): finish unit 8 lesson 1 activities
Browse files Browse the repository at this point in the history
  • Loading branch information
101zh committed Jan 31, 2024
1 parent 7ee92f7 commit 3a31053
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/Unit8/U8_L1_Activity_One.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
18 changes: 18 additions & 0 deletions src/main/java/Unit8/U8_L1_Activity_Two.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 3a31053

Please sign in to comment.