forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTables.java
More file actions
45 lines (38 loc) · 958 Bytes
/
Tables.java
File metadata and controls
45 lines (38 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Generating tables.
*/
public class Tables {
public static void example() {
int i = 1;
while (i < 10) {
double x = i;
System.out.println(x + " " + Math.log(x));
i = i + 1;
}
}
public static void example2() {
int i = 1;
while (i < 10) {
double x = i;
System.out.println(x + " " + Math.log(x) / Math.log(2));
i = i + 1;
}
}
public static void example3() {
final double LOG2 = Math.log(2);
int i = 1;
while (i < 100) {
double x = i;
System.out.println(x + " " + Math.log(x) / LOG2);
i = i * 2;
}
}
public static void main(String[] args) {
System.out.println("example");
example();
System.out.println("example2");
example2();
System.out.println("example3");
example3();
}
}