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.
문제
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.