为什么bmiHeight / bmieWeight返回0

时间:2019-05-17 06:02:16

标签: ios swift xcode mobile

我正试图在快速的操场上为iOS开发挑战创建一个BMI计算器,它可以使用所有其他算法,但是在尝试除以bmiHeight / bmiWeight时仅返回0

import UIKit

func bmiCalculator(height : Int, weight : Int) -> String {

    let bmiHeight = height * 703
    let bmiWeight = weight * weight
    let bmiEquation = bmiHeight / bmiWeight


    if bmiEquation > 25 {

        return "Your BMI is (bmiEquation). You are  overweight"
    }

    else if bmiEquation > 18 &&  bmiEquation <= 25 {

        return "Your BMI is (bmiEquation). You are in the normal range"
    }

    else {

        return "Your BMI is (bmiEquation). You are underweight"
    }
}

print(bmiCalculator(height: 72, weight: 230))

0 个答案:

没有答案