Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top