<span style="font-size:32px;">//
// ZYAppDelegate.m
// Shuilv
//
// Created by mac on 15-7-30.
// Copyright (c) 2015年 zhiyou. All rights reserved.
//
#import "ZYAppDelegate.h"
@implementation ZYAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UILabel *gongzi=[[UILabel alloc] initWithFrame:CGRectMake(20, 30, 50, 30)];
gongzi.text=@"工资:";
gongzi.textAlignment=NSTextAlignmentCenter;
gongzi.backgroundColor=[UIColor redColor];
[self.window addSubview:gongzi];
gongzitf=[[UITextField alloc] initWithFrame:CGRectMake(80, 30, 200, 30)];
gongzitf.borderStyle=UITextBorderStyleRoundedRect;
gongzitf.placeholder=@"请输入工资";
[self.window addSubview:gongzitf];
UILabel *sanxianlb=[[UILabel alloc] initWithFrame:CGRectMake(20, 80, 50, 30)];
sanxianlb.text=@"三险:";
sanxianlb.textAlignment=NSTextAlignmentCenter;
sanxianlb.backgroundColor=[UIColor redColor];
[self.window addSubview:sanxianlb];
sanxiantf=[[UITextField alloc] initWithFrame:CGRectMake(80, 80, 200, 30)];
sanxiantf.borderStyle=UITextBorderStyleRoundedRect;
[self.window addSubview:sanxiantf];
UILabel *kousanlb=[[UILabel alloc] initWithFrame:CGRectMake(20, 130, 50, 30)];
kousanlb.text=@"扣三:";
kousanlb.textAlignment=NSTextAlignmentCenter;
kousanlb.backgroundColor=[UIColor redColor];
[self.window addSubview:kousanlb];
// 扣除后
kousantf=[[UITextField alloc] initWithFrame:CGRectMake(80, 130, 200, 30)];
kousantf.borderStyle=UITextBorderStyleRoundedRect;
[self.window addSubview:kousantf];
UILabel *yingnalb=[[UILabel alloc] initWithFrame:CGRectMake(20, 180, 50, 30)];
yingnalb.text=@"应纳:";
yingnalb.textAlignment=NSTextAlignmentCenter;
yingnalb.backgroundColor=[UIColor redColor];
[self.window addSubview:yingnalb];
//
yingnatf=[[UITextField alloc] initWithFrame:CGRectMake(80, 180, 200, 30)];
yingnatf.borderStyle=UITextBorderStyleRoundedRect;
[self.window addSubview:yingnatf];
UILabel *suodeshuilb=[[UILabel alloc] initWithFrame:CGRectMake(20, 230, 80, 30)];
suodeshuilb.text=@"所得税:";
suodeshuilb.textAlignment=NSTextAlignmentCenter;
suodeshuilb.backgroundColor=[UIColor redColor];
[self.window addSubview:suodeshuilb];
//
suodeshuitf=[[UITextField alloc] initWithFrame:CGRectMake(115, 230, 180, 30)];
suodeshuitf.borderStyle=UITextBorderStyleRoundedRect;
[self.window addSubview:suodeshuitf];
UIButton *cal=[UIButton buttonWithType:UIButtonTypeCustom];
cal.frame=CGRectMake(140, 400, 60, 30);
[cal setTitle:@"计算" forState:UIControlStateNormal];
cal.backgroundColor=[UIColor blueColor];
[cal addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:cal];
return YES;
}
-(void)click{
a=[gongzitf.text floatValue];
if (a>=7662) {
sanxian=7662*(0.08+0.02+0.005+0.12);
}else{
sanxian=a*(0.08+0.02+0.005+0.12);
}
sanxiantf.text=[NSString stringWithFormat:@"%.2f",sanxian];
kousan=a-sanxian;
kousantf.text=[NSString stringWithFormat:@"%.2f",kousan];
yingna=kousan-3500;
if (yingna>=0) {
yingnatf.text=[NSString stringWithFormat:@"%.2f",yingna];
}else{
yingnatf.text=[NSString stringWithFormat:@"%.2f",0.00];
}
if (yingna>0) {
if (yingna<=1500) {
suodeshui=yingna*0.03;
NSLog(@"1111111111=====%f",suodeshui);
}else if (yingna>1500&&yingna<=4500) {
suodeshui=yingna*0.1-105;
NSLog(@"222222222=====%f",suodeshui);
}else if (yingna>4500&&yingna<=9000) {
suodeshui=yingna*0.2-555;
NSLog(@"333333333====%f",suodeshui);
}else if (yingna>9000&&yingna<=35000) {
suodeshui=yingna*0.25-1005;
NSLog(@"44444444444====%f",suodeshui);
}else if (yingna>35000&&yingna<=55000) {
suodeshui=yingna*0.3-2755;
NSLog(@"5555555555====%f",suodeshui);
}else if (yingna>55000&&yingna<=80000) {
suodeshui=yingna*0.35-5505;
NSLog(@"6666666====%f",suodeshui);
}else if (yingna>80000) {
suodeshui=yingna*0.45-13505;
NSLog(@"77777777====%f",suodeshui);
}
}
else{
suodeshui=0;
}
suodeshuitf.text=[NSString stringWithFormat:@"%.2f",suodeshui];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.window endEditing:YES];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
</span>
<span style="font-size:32px;">
</span>
<span style="font-size:32px;"><img src="https://img-blog.csdn.net/20150730215123327?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
</span>