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.

9 changes: 5 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
It is mutable as it is a point, and points are mutable.
```

```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
Number 3 returns a primitive, number 4 returns an object.
```

```java
Expand Down Expand Up @@ -87,14 +87,15 @@ 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
(5,8)
(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
p1 and p2 are aliased as they both refer to box1.
```

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


public class BigIntRewrite {
public static void main(String[] args) {
BigInteger pow = pow(6, 4);
System.out.println(pow);

}
public static BigInteger pow(int x, int n) {
if (n == 0) return BigInteger.ONE; // BigInteger constant for 1 (had to look this up)
// find x to the n/2 recursively
BigInteger t = pow(x, n / 2);
// if n is even, the result is t squared
// if n is odd, the result is t squared times x
if (n % 2 == 0) {
return t.multiply(t);
} else {
return t.multiply(t).multiply(BigInteger.valueOf(x));
}
}
}
24 changes: 24 additions & 0 deletions src/StringPlayground.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
import java.util.Scanner;

public class StringPlayground {
public static void main(String[] args) {
String s;
Scanner in = new Scanner(System.in);
System.out.println("Input what you wish to check.");
s = in.nextLine();
int count = findChar(s);
System.out.println(count);
}



public static int findChar(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;
}
in.close();
}