I should have qualified the above with: _ and I will be performing operations on the numeric datatype, since just outputting simply strings, as in the above example, would require nothing more than string data types. :)
```d
module hello_world;

import std.stdio;
import std.string; // strip()
import std.conv; // to!int(),to!float()

void main() {
        writeln("Hello world from D!");
        write("What is your name? ");
        auto fname = readln.strip;
        writeln("It's so nice to meet you ", fname, "!");
        write("How old are you? ");
        auto age = to!int(readln.strip);
        write("What is your GPA? ");
        auto gpa = to!float(readln.strip);
        if (gpa > 4) {
                writeln("Sorry, 4 is the highest GPA ");
                gpa = 4; }
writeln("So, ", fname, ", you are ", age, " years old and your GPA is ",
                gpa, ".. stellar!");
        writeln("Can you increase your GPA? ");
        if(gpa == 4) {
                writeln("Your GPA is already as high as it can be!");
        } else {                
                gpa = gpa > 3.5 ? 4 : (gpa + 0.5);
                writeln("If you study hard, your GPA will likely be ", gpa);
                age = age + 4;
writeln("But that may take 4 years, and you will be ", age, " years old by that time.");
        }
}
```

Reply via email to