`` Ideal
`` Public Domain

`` Algorithms
`` http://www.scriptol.net


/*
   Function BodyMassIndex()
   Input: height in cm, weight in kg
   Returns:
   - the Body Mass Index (BMI)
   - or nil if invalid height entered.
*/


int BMI(int height, int weight)
    if (height < 20) or (height > 300) return nil
    real formula =  ( ( real(weight) * 10000 / ((height * height)) + 0.5))
return int(formula)


int main(int argc, array argv)

    int b, h, w
    int count = 0

    if argc < 3
        print "Usage: ideal height-in-cm weight-in-kg"
        return 0
    /if

    h = argv[1].toInt()
    w = argv[2].toInt()

    if (h < 20) or (h > 300)
        print "Height", h, "out of range..."
        return 0
    /if

    if (w < 20)
        print "Weight", w,"out of range..."
        return 0
    /if

    b = BMI(h, w)

    print "Height", h, "centimeters, weight", w, "kilogs, body mass", b

    if b < 25
        print "Congratulations! Your are within the recommended range."
    else
        do
            w - 1
            count + 1
            b = BMI(h, w)
        until b <= 24

        print "Your index is above the recommended level of 24..."
        print "you must drop", count, "kg","to reach", w, "kg."
    /if

return 1

main($argc, $argv)