Last active
September 10, 2017 03:20
-
-
Save jcouyang/edc3d175769e893b39e6c5be12a8526f to your computer and use it in GitHub Desktop.
BMI Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
height = params['height'].to_f | |
weight = params['weight'].to_f | |
bmi = weight * 10000.0 / (height * height) | |
health = if(bmi < 18.5) | |
'underweight' | |
elsif (bmi < 24.9) | |
'normal' | |
elsif (bmi < 30) | |
'Overweight' | |
elsif (bmi >= 30) | |
'Obese' | |
end | |
{ | |
:health => health, | |
:bmi => bmi.round(2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment