Haskell --- Body Mass Index P87082


Statement
 

pdf   zip

The Body Mass Index (BMI) is a number that allows evaluating a person’s corpulence by relating their mass to their height. It was developed by the Belgian Adolphe Quételet while elaborating his system of “social physics" between the years 1830 and 1850 and is also known as the Quételet Index. Its formula is 𝐵𝑀𝐼=mh2,\textit{BMI} = \frac{m}{h^2}, where mm is the person’s mass (in kilograms) and hh their height (in meters).

Its interpretation (applicable only to adults) is as follows:

BMI Interpretation
less than 18 underweight
18 to 25 normal corpulence
25 to 30 overweight
30 to 40 obesity
more than 40 morbid obesity

Write a Haskell program to interpret the body mass index of different people.

Input

The input is organized by lines. Each line contains three elements separated by spaces: name, weight, and height. The last line is special and contains only an asterisk.

Output

For each input data, write their name and the interpretation of their BMI.

Observation

To solve this problem in Haskell, write a main function and choose the GHC compiler.

Public test cases
  • Input

    Joan 76 1.80
    Merce 66 1.50
    Felip 100 2.01
    Ramon 90.9 1.70
    Anna 40 1.70
    Maria 120 1.60
    *
    

    Output

    Joan: corpulencia normal
    Merce: sobrepes
    Felip: corpulencia normal
    Ramon: obesitat
    Anna: magror
    Maria: obesitat morbida
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    Haskell
    User solutions
    Haskell