Skip to content

Commit

Permalink
sync with 6.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMayfield committed Dec 27, 2016
1 parent 390cbbe commit 9fb1ef4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions ch05/Logarithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ public static void main(String[] args) {
System.out.println("printLogarithm");
printLogarithm(3.0);

Scanner in = new Scanner(System.in);

System.out.println("scandouble");
scanDouble();
scanDouble(in);

System.out.println("scandouble2");
scanDouble2();
scanDouble2(in);
}

public static void printLogarithm(double x) {
Expand All @@ -22,15 +24,13 @@ public static void printLogarithm(double x) {
System.out.println("The log of x is " + result);
}

public static void scanDouble() {
Scanner in = new Scanner(System.in);
public static void scanDouble(Scanner in) {
System.out.print("Enter a number: ");
double x = in.nextDouble();
printLogarithm(x);
}

public static void scanDouble2() {
Scanner in = new Scanner(System.in);
public static void scanDouble2(Scanner in) {
System.out.print("Enter a number: ");
if (!in.hasNextDouble()) {
String word = in.next();
Expand Down
6 changes: 3 additions & 3 deletions ch07/Tables.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Tables {
public static void example() {
int i = 1;
while (i < 10) {
double x = (double) i;
double x = i;
System.out.println(x + " " + Math.log(x));
i = i + 1;
}
Expand All @@ -15,7 +15,7 @@ public static void example() {
public static void example2() {
int i = 1;
while (i < 10) {
double x = (double) i;
double x = i;
System.out.println(x + " " + Math.log(x) / Math.log(2));
i = i + 1;
}
Expand All @@ -25,7 +25,7 @@ public static void example3() {
final double LOG2 = Math.log(2);
int i = 1;
while (i < 100) {
double x = (double) i;
double x = i;
System.out.println(x + " " + Math.log(x) / LOG2);
i = i * 2;
}
Expand Down

0 comments on commit 9fb1ef4

Please sign in to comment.