Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Is the **blank** object mutable or immutable? How can you tell?

```text
PUT ANSWER TO #2 HERE
PUT ANSWER TO #2 HERE: The object is mutable because it can be changed.
```

```java
Expand Down Expand Up @@ -47,7 +47,7 @@ public class Puzzler {
* Explain how the return values from #3 and #4 differ.

```text
PUT ANSWER TO #5 HERE
PUT ANSWER TO #5 HERE: #3 is a point object. #4 is a double.
```

```java
Expand Down Expand Up @@ -87,14 +87,14 @@ Recall that aliases are two variables that refer to the same object.
* Put the output in the text block below

```text
PUT ANSWER TO #2 HERE
PUT ANSWER TO #2 HERE: (5,8)
```

3. At the end of main, are p1 and p2 aliased? Why or why not?
* Put your answer in the text block below

```text
PUT ANSWER TO #3 HERE
PUT ANSWER TO #3 HERE: P1 and P2 are not aliased since they are different objects.
```

```java
Expand Down
23 changes: 23 additions & 0 deletions src/BigIntRewrite.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
import java.math.BigInteger;

public class BigIntRewrite {
public static BigInteger pow(int x, int n) {
BigInteger result = BigInteger.ONE;
BigInteger number = BigInteger.valueOf(x);

while (n > 0) {
if (n % 2 == 1) {
result = result.multiply(number);
}
number = number.multiply(number);
n /= 2;
}


return result;
}

public static void main(String[] args) {

int number = 2;
int exponent = 10;
BigInteger result = pow(number, exponent);

System.out.println(number + " raised to the power of " + exponent + " is: " + result);
}
}
Binary file added src/P3_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/StringPlayground.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
public class StringPlayground {

public static int countParentheses(String s) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '(') {
count++;
} else if (c == ')') {
count--;
}
}
return count;
}


public static void main(String[] args) {
String[] testStrings = {"((3 + 7) * 2)", "((3 + 7) * 2))"};

for (String testString : testStrings) {
int result = countParentheses(testString);

System.out.println("String: " + testString + ", Parentheses count: " + result);
}
}
}
Binary file added src/p1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/p1_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/p1_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/p2_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.