We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee99f76 commit cd34cf8Copy full SHA for cd34cf8
1 file changed
ch03/Convert.java
@@ -8,17 +8,18 @@ public class Convert {
8
public static void main(String[] args) {
9
double cm;
10
int feet, inches, remainder;
11
- final double centPerInch = 2.54;
+ final double CM_PER_INCH = 2.54;
12
+ final int IN_PER_FOOT = 12;
13
Scanner in = new Scanner(System.in);
14
15
// prompt the user and get the value
16
System.out.print("Exactly how many cm? ");
17
cm = in.nextDouble();
18
19
// convert and output the result
- inches = (int) (cm / centPerInch);
20
- feet = inches / 12;
21
- remainder = inches % 12;
+ inches = (int) (cm / CM_PER_INCH);
+ feet = inches / IN_PER_FOOT;
22
+ remainder = inches % IN_PER_FOOT;
23
System.out.printf("%.2f cm = %d ft, %d in\n",
24
cm, feet, remainder);
25
}
0 commit comments