Doing unit conversion prog, touching up Makefile
This commit is contained in:
19
d/prog-lang-book/src/height_conversions.d
Normal file
19
d/prog-lang-book/src/height_conversions.d
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Compute heights in centimeters for a range of heights
|
||||
expressed in feet and inches
|
||||
*/
|
||||
import std.stdio;
|
||||
|
||||
void main() {
|
||||
// Values unlikely to change soon
|
||||
immutable inchesPerFoot = 12;
|
||||
immutable cmPerInch = 2.54;
|
||||
|
||||
// Loop'n write
|
||||
foreach (feet; 5 .. 7) {
|
||||
foreach (inches; 0 .. inchesPerFoot) {
|
||||
writeln(feet, "'", inches, "''\t",
|
||||
(feet * inchesPerFoot + inches) * cmPerInch);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user