-1

こんにちは私は重みのifステートメントを使用してxcodeを初めて使用します

int weight;

if (weight <10) { 
([ input.text * @" 100 " Floatvalue); }

if (weight 10-20){ 
([ input.text == 1000 + 50 for each kg more than 10);}

if (weight >20 ){
([ input.text == 1000 + 20 for each kg more than 20);}
4

1 に答える 1

2

あなたの質問を理解した場合 (たとえば、出力を文字列として欲しいと収集した場合)、次のようにするとうまくいく可能性があります。

if (weight < 10) {
    input.text = [NSString stringWithFormat:@"%d", 100 * weight];  // I'm not really sure what you wanted to do here.
}
else if (weight > 20) {
    input.text = [NSString stringWithFormat:@"%d", 1000 + 20 * (weight - 20)];
}
else {
    input.text = [NSString stringWithFormat:@"%d", 1000 + 50 * (weight - 10)];
}
于 2012-07-18T06:55:05.283 に答える