iOS Objective C Programming Xcode using if statements -


So I'm trying to use the statements in an app so that someone calculates the body mass index (BMI) Able to I need the user to be able to input metric or imperial units for weight and height and I really want the user to be able to get input metric weight, for example, and get royal height. I thought it would be best to use the I statement and my code is below. At present, I have been given warnings about the statement and it just does not pay attention to them. Thanks a lot for any help.

  - Calculate (IBAction) process: (ID) sender {float cm = [_cmHeight.text floatValue]; Float foot = [_feetHeight.text float value]; Float inches = [_inchesHeight.text float value]; Float kg = [_kgWeight.text float value]; Float stone = [_stoneWeight.text float value]; Boat pound = [_poundWeight.text float value]; Float height; Float mass; If (cm == 0) {float height = 0.3048 * feet + 0.0254 * inches; } And {float height = cm / 100; } If (kg == 0) {float mass = (6.35029 * stone) + (0.453592 * pounds); } And {float mass = cm / 100; Float BMI = Mass / (height * height); [_resultLabel setText: [NSString stringWithFormat: @ "% .2f", BMI]]; }   

if-other blocks stack variable redeclare height and mass , then if the code after the second block will not see the conditional result change ...

  // ... float height; Float mass; If (cm == 0) see {// - a float type height = 0.3048 * ft + 0.0254 * inch; } And {height = cms / 100; } If (kg == 0) {mass = (6.35029 * stone) + (0.453592 * pounds); } And {mass = cm / 100; }   

On the one hand, both statements can be made more condensed in this way:

  height = (cm == 0)? 0.3048 × ft + 0.0254 * inch: cm / 100; Mass = (kg == 0)? (6.35029 * stone) + (0.453592 * pound): cm / 100;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -