Skip to content

Commit 2b9b3d6

Browse files
committed
added missing exercises
1 parent b006db3 commit 2b9b3d6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

ch05/Buzz.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class Buzz {
2+
3+
public static void baffle(String blimp) {
4+
System.out.println(blimp);
5+
zippo("ping", -5);
6+
}
7+
8+
public static void zippo(String quince, int flag) {
9+
if (flag < 0) {
10+
System.out.println(quince + " zoop");
11+
} else {
12+
System.out.println("ik");
13+
baffle(quince);
14+
System.out.println("boo-wa-ha-ha");
15+
}
16+
}
17+
18+
public static void main(String[] args) {
19+
zippo("rattle", 13);
20+
}
21+
22+
}

ch06/Recursive.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Recursive {
2+
3+
public static void main(String[] args) {
4+
System.out.println(prod(1, 4));
5+
}
6+
7+
public static int prod(int m, int n) {
8+
if (m == n) {
9+
return n;
10+
} else {
11+
int recurse = prod(m, n-1);
12+
int result = n * recurse;
13+
return result;
14+
}
15+
}
16+
17+
}

0 commit comments

Comments
 (0)