Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd34cf8

Browse filesBrowse files
committed
ch03 sync w/book
1 parent ee99f76 commit cd34cf8
Copy full SHA for cd34cf8

File tree

Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Collapse file

‎ch03/Convert.java‎

Copy file name to clipboardExpand all lines: ch03/Convert.java
+5-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.