import std.stdio, std.math, std.string; void main() { writefln("This is an application to work out the reverberation time (RT60) of a rectangular room Firstly, you will need to understand which wall is which: 1 - The wall on your left 2 - The wall in front of you 3 - The wall on your right 4 - The wall behind you 5 - The ceiling 6 - The floor"); float readline(string label) { writef(label); return atof(readln); } writefln("Please enter the dimensions of the room in m"); auto height=abs(readline("Height: ")); auto width=abs(readline("Width: ")); auto length=abs(readline("Length: ")); auto volume=height*width*length; writefln("Now, please enter the absorption co-efficients of the surfaces in the room. Values must be equal either 0 or 1, or lie between them. If the value entered does not, you will be asked to enter again."); float[string] walls=[ "Left"[]: height*length, "Right": height*length, "Roof": width*length, "Floor": width*length, "Front": width*height, "Back": width*height ]; float a=0; foreach (name, area; walls) { float ain; do ain=readline(name~": "); while (ain<0 || ain>1); a += ain*area; } // Now that we have all the variables needed, we can work out the reverberation time, using the sabine equation. float reverberationtime = (0.161*volume)/a; writefln("The reverberation time of this room is ", reverberationtime, " seconds."); }