문제

There are 2 textfields named as "liter" and "kronor". The user will type in two numbers, with decimals, in here.

I have a label where I want to divide "kronor" with "liter" (kronor/liter).

- (IBAction)prischeck:(id)sender {
    float x=[_kronor.text floatValue];
    float y=[_liter.text floatValue];
    float z= x/y;
}

Have I done it right?

도움이 되었습니까?

해결책

literpriset.text = [NSString stringWithFormat:@"%f", z];

or

literpriset.text = [NSString stringWithFormat:@"%f / %f = %f", x, y, z];

if you need to display also x and y.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top