我正在制作小费计算器,这是我目前拥有的代码:(下)。[为了让它看起来不错],有没有办法让用户只输入 (15),然后让代码在后台显示 0.15?谢谢
- (IBAction)calcTapped:(id)sender {
NSString *billAmountString = [billAmountTextField text];
float billAmountFloat = [billAmountString floatValue];
NSString *tipPercentString = [tipPercentTextField text];
float tipPercentFloat = [tipPercentString floatValue];
float tipAmount = billAmountFloat * tipPercentFloat;
NSString *result = [NSString stringWithFormat:@"Tip: %0.2f",
tipAmount];
[resultLabel setText:result];
}