generated from microsoft/vscode-remote-try-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(8.1): finish unit 8 lesson 1 activities
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |