0
我要問的問題聽起來真的很愚蠢,但我正在努力尋找辦法。在計算中設置最大值
我正在爲我的公司製作計算器。 在我的演算,我想所顯示的最大值不超過120
例:
12*2= 24
12*10= 120
12*97403= 120
我知道它只是失去了一些東西可笑的在我的代碼,但我不能找到解決辦法在互聯網上。 我只是一個正在向我奮鬥的新手!哈哈
我給你我所做的。 如果你可以花20秒鐘告訴我我要補充什麼,我將不勝感激。 :)我的代碼是: h。
@interface ViewController : UIViewController
{
IBOutlet UITextField *pourcent;
IBOutlet UITextField *ans;
IBOutlet UITextField *heuresdif;
IBOutlet UITextField *heuresacquises;
IBOutlet UILabel *DIF;
IBOutlet UILabel *MONTANT;
}
-(IBAction)calculator;
-(IBAction)clean;
@property (strong, nonatomic) IBOutlet UILabel *myLabel;
@property (strong, nonatomic) IBOutlet UITextField *textField;
@end
和m。
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
-(IBAction)calculator {
float a = ([ans.text floatValue]);
float b = ([pourcent.text floatValue]);
float c = ([heuresdif.text floatValue]);
float d = ([heuresacquises.text floatValue]);
// Heures de DIFF Restant
float f = (a*20*b/100)-c+d;
// Montant du DIF
float g = f*9.53;
DIF.text = [[NSString alloc]initWithFormat:@"%0.0f", f];
MONTANT.text = [[NSString alloc]initWithFormat:@"%0.2f", g];
}
-(IBAction)clean {
ans.text = @"";
pourcent.text = @"";
heuresdif.text = @"";
heuresacquises.text = @"";
}
@end
對不起我的意思是12 * 2 = 24很明顯! :) – Sebsocs