box-o-sand/d/prog-lang-book/src/height_conversions.d

20 lines
460 B
D
Raw Normal View History

/*
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) {
writefln("%s'%s''\t%s", feet, inches,
(feet * inchesPerFoot + inches) * cmPerInch);
}
}
}