DEV Community

Discussion on: Daily Challenge #57 - BMI Calculator

Collapse
 
lprakashv profile image
Lalit Vatsal

Scala:

object Body {
    def calculateBMI(weight: Double, height: Double): String = (weight / (height * height)) match {
        case x if x <= 18.5 => "Underweight"
        case x if x <= 25 => "Normal"
        case x if x <= 30 => "Overweight"
        case _ => "Obsese"
    }
}