Firstly Thanks to all upcoming answers .
I am new to swift
programming . I am testing out many things lol . I am trying to do a bmi
app. I am using print()
in order to check all values of my variables.
I am not able to understand why imc
value is 0
. Did I miss something ? What's the logic? I tried to hard code it with quotien 90/32400
or x/ySquare
same result. I am still getting quotien = 0
import UIKit class ViewController: UIViewController { @IBOutlet weak var weightTextField: UITextField! @IBOutlet weak var heightTextfield: UITextField! @IBOutlet weak var resultLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func calculateButton(_ sender: Any) { imcCalculator() } func imcCalculator () { let myHeight = Int(heightTextfield.text!) let myWeight = Int(weightTextField.text!) let x = myWeight! let y = myHeight! //let imc = Int(Int(x / pow(y, 2)) * 10000) let ySquare = y * y let quotien = 90 / 32400 let imc = (x/ySquare)*10000 if imc > 25 { resultLabel.text = " Your BMI is \(imc) . You are overweight" } else if imc 18 { resultLabel.text = " Your BMI is \(imc) . You have a normal weight" } else { resultLabel.text = "Your BMI is \(imc) . You are underweight" } print(x) print(y) print(ySquare) print(quotien) print(imc) } }