Haskell - Body mass index P87082


Statement
 

pdf   zip

thehtml

The body mass index (BMI) is an attempt to quantify the amount of tissue mass (muscle, fat, and bone) in an individual, and then categorize that person as underweight, normal weight, overweight, or obese based on that value.

The BMI was conceived by Adolphe Quételet between 1830 and 1850 its formula is

    BMI = 
m
h2
,

where m is the mass of an individual (in kilograms) ans h is its height (en meters).

Its interpretation (only for adults) is the following:

BMIInterpretation
less than 18underweight
from 18 to 25normal weight
from 25 to 30overweight
from 30 to 40obese
more than 40severely obese

Write a Haskell program to interpret the body mass index of several individuals.

Input

Input is organized in lines. Each line has three elements separated with whitespaces: the name, the weight and the height. The last line is special and only contains an asterisc.

Output

For each individual, print his/her name and the interpretation of his/her BMI.

Observation

In order to solve this problem in Haskell, write a main action and choose the GHC compiler.

Public test cases
  • Input

    John 76 1.80
    Mary 66 1.50
    Phil 100 2.01
    Raymond 90.9 1.70
    Ann 40 1.70
    Edith 120 1.60
    *
    

    Output

    John: normal weight
    Mary: overweight
    Phil: normal weight
    Raymond: obese
    Ann: underweight
    Edith: severely obese
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    Haskell
    User solutions
    Haskell