Skip to content

Commit cd34cf8

Browse files
committed
ch03 sync w/book
1 parent ee99f76 commit cd34cf8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ch03/Convert.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ public class Convert {
88
public static void main(String[] args) {
99
double cm;
1010
int feet, inches, remainder;
11-
final double centPerInch = 2.54;
11+
final double CM_PER_INCH = 2.54;
12+
final int IN_PER_FOOT = 12;
1213
Scanner in = new Scanner(System.in);
1314

1415
// prompt the user and get the value
1516
System.out.print("Exactly how many cm? ");
1617
cm = in.nextDouble();
1718

1819
// convert and output the result
19-
inches = (int) (cm / centPerInch);
20-
feet = inches / 12;
21-
remainder = inches % 12;
20+
inches = (int) (cm / CM_PER_INCH);
21+
feet = inches / IN_PER_FOOT;
22+
remainder = inches % IN_PER_FOOT;
2223
System.out.printf("%.2f cm = %d ft, %d in\n",
2324
cm, feet, remainder);
2425
}

0 commit comments

Comments
 (0)