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