#import <Foundation/Foundation.h>
@interface calculator :
NSObject
//@property double number;
+(void)texe;
+(void)add:(float)num1 andnum2:(float)num;
+(void)subtract:(float)num1 andnum2:(float)num2;
+(void)multiply:(float)num1 andnum2:(float)num2;
+(void)divice:(float)num1 andnum2:(float)num2;
@end
@implementation calculator
+(void)texe
{
NSLog(@"这是一个测试方法");
}
//加法
+(void)add:(float)num1 andnum2:(float)num2
{
NSLog(@"%.2f+%.2f=%.2f",num1,num2,num1+num2);
}
//减法
+(void)subtract:(float)num1 andnum2:(float)num2{
NSLog(@"%.2f-%.2f=%.2f",num1,num2,num1-num2);
}
//乘法
+(void)multiply:(float)num1 andnum2:(float)num2{
NSLog(@"%.2f*%.2f=%.2f",num1,num2,num1*num2);
}
//除法
+(void)divice:(float)num1 andnum2:(float)num2{
NSLog(@"%.2f ÷ %.2f=%.2f",num1,num2,num1/num2);
}
@end
int main(int argc,const
char * argv[]) {
@autoreleasepool {
//加法
[calculatoradd:12.3andnum2:12.3];
//减法
[calculatorsubtract:25andnum2:10];
//乘法
[calculatormultiply:12andnum2:2.5];
//除法
[calculatordivice:30andnum2:2];
}
return0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。