需求:
1、有登陆操作,超过三次需重新打开登录
2、查询五险一金、税前税后工资计算,个人与单位应缴明细
3、输入税后工资和税前工资都可查询
4、退出有询问确认操作
代码如下;
#include<stdio.h> #include<stdlib.h> double PEI; //个人应缴养老保险金额 double PMI; //个人应缴医疗保险金额 double PUI; //个人应缴失业保险金额 double PEII; //个人应缴工伤保险金额 double PMTI; //个人应缴生育保险金额 double PHF; //个人应缴住房公积金金额 double CEI; //单位应缴养老保险金额 double CMI; //单位应缴医疗保险金额 double CUI; //单位应缴失业保险金额 double CEII; //单位应缴工伤保险金额 double CMTI; //单位应缴生育保险金额 double CHF; //单位应缴住房公积金金额 double Pt; //税前工资 double T; //税金 double At; //税后工资 double Tt=3500.0; //起征点 double Tr; //税率 double Q; //速算扣除数 double SH; //个人应缴社保和住房公积金总额 double Qt; //全月应纳税所得额 void InputPreTaxWages() { printf("请输入税前工资:"); scanf("%lf",&Pt); } //计算税前工资 double PreTaxWages() { printf("请输入税后工资:"); scanf("%lf",&At); //不同的税后工资税率不同 if (0<=At&&At<=3500){T=((At-3500)*0-0)/(1-0);} else if (3500<At&&At<=4955){T=((At-3500)*0.03-0)/(1-0.03);} else if (4955<At&&At<=7655){T=((At-3500)*0.1-105)/(1-0.1);} else if (7555<At&&At<=11255){T=((At-3500)*0.2-555)/(1-0.2);} else if (11255<At&&At<=30755){T=((At-3500)*0.25-1005)/(1-0.25);} else if (30755<At&&At<=44755){T=((At-3500)*0.3-2755)/(1-0.3);} else if (44755<At&&At<=61005){T=((At-3500)*0.35-5505)/(1-0.35);} else if (61005<At){T=((At-3500)*0.45-13505)/(1-0.45);} Pt = (At + T + 3)/(0.778); //税后反推税前工资公式:税前工资=(税后工资+个人所得税+3)/0.778 } //计算税后工资 double AfterTaxWages() { printf("请输入税前工资:"); scanf("%lf",&Pt); SH = (Pt*0.222)+3; //计算个人应缴社保住房公积金总额公式:(税前工资*0.222)+3 Qt = Pt-SH-Tt; //计算个人全月应纳税所得额公式:(税前工资-个人应缴社保和住房公积金-起征点) //计算应缴个人所得税公式:(个人全月应纳税所得额*税率-速算扣除数) //不同的税前工资税率不同 if (Qt<=0){T=0;} else if (0<Qt&&Qt<=1500){T=Qt*0.03-0;} else if (1500<Qt&&Qt<=4500){T=Qt*0.1-105;} else if (4500<Qt&&Qt<=9000){T=Qt*0.2-555;} else if (9000<Qt&&Qt<=35000){T=Qt*0.25-1005;} else if (35000<Qt&&Qt<=55000){T=Qt*0.3-2755;} else if (55000<Qt&&Qt<=80000){T=Qt*0.35-5505;} else if (Qt>80000){T=Qt*0.45-13505;} At = Pt-SH-T; //税后工资计算公式:税前工资-个人应缴社保公积金-个人所得税 printf("税后工资为%.2lf\n",At); //输出税后工资 printf("=================================\n"); } //计算养老保险 void CalculateEndowmentInsurance(double Pt) { PEI=Pt*0.08; //计算个人应缴养老保险金额 CEI=Pt*0.19; //计算单位应缴养老保险金额 printf("个人应缴养老保险金额:%.2lf\n",PEI); //输出个人应缴养老保险金额 printf("单位应缴养老保险金额:%.2lf\n",CEI); //输出单位应缴养老保险金额 printf("应缴养老保险合计是:%.2lf\n",CEI+PEI); printf("=================================\n"); } //养老保险 void EndowmentInsurance() { int b = 1; void CalculateEndowmentInsurance(double Pt); while(b) { int a; printf("1:输入税前工资计算养老保险\n""2:输入税后工资计算养老保险\n""0:返回上一级菜单\n"); printf("请输入查询编号:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: InputPreTaxWages(); CalculateEndowmentInsurance(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateEndowmentInsurance(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //计算医疗保险 void CalculateMedicalInsurance(double Pt) { PMI=Pt*0.02+3; //计算个人应缴医疗保险金额 CMI=Pt*0.1; //计算单位应缴医疗保险金额 printf("个人应缴医疗保险金额:%.2lf\n",PMI); //输出个人应缴医疗保险金额 printf("单位应缴医疗保险金额:%.2lf\n",CMI); //输出单位应缴医疗保险金额 printf("应缴医疗保险合计是:%.2lf\n",PMI+CMI); printf("=================================\n"); } //医疗保险 void MedicalInsurance() { int b = 1; void CalculateMedicalInsurance(double Pt); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算医疗保险\n""2:输入税后工资计算医疗保险\n""0:返回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 CalculateMedicalInsurance(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateMedicalInsurance(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //计算失业保险 void CalculateUnInsurance(double Pt) { PUI=Pt*0.002; //计算个人应缴失业保险金额 CUI=Pt*0.008; //计算单位应缴失业保险金额 printf("个人应缴失业保险金额:%.2lf\n",PUI); //输出个人应缴失业保险金额 printf("单位应缴失业保险金额:%.2lf\n",CUI); //输出单位应缴失业保险金额 printf("应缴失业保险合计是:%.2lf\n",PUI+CUI); printf("=================================\n"); } //失业保险 void UnemploymentInsurance() { int b = 1; void CalculateUnInsurance(double Pt); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算失业保险\n""2:输入税后工资计算失业保险\n""0:返回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 CalculateUnInsurance(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateUnInsurance(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //计算工伤保险 void CalculateInjuryInsurance(double Pt) { PEII=0; //个人应缴工伤保险为零 CEII=Pt*0.005; //计算单位应缴失业保险金额 printf("个人应缴工伤保险金额:%.2lf\n",PEII); //输出个人应缴工伤保险金额 printf("单位应缴工伤保险金额:%.2lf\n",CEII); //输出单位应缴工伤保险金额 printf("应缴工伤保险合计是:%.2lf\n",PEII+CEII); printf("=================================\n"); } //工伤保险 void InjuryInsurance() { int b = 1; void CalculateInjuryInsurance(double Pt); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算工伤保险\n""2:输入税后工资计算工伤保险\n""0:返回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 CalculateInjuryInsurance(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateInjuryInsurance(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //计算生育保险 void CalculateMaternityInsurance(double Pt) { PMTI=0; //个人应缴生育保险为零 CMTI=Pt*0.008; //计算单位应缴生育保险金额 printf("个人应缴生育保险金额:%.2lf\n",PMTI); //输出个人应缴生育保险金额 printf("单位应缴生育保险金额:%.2lf\n",CMTI); //输出单位应缴生育保险金额 printf("应缴生育保险合计是:%.2lf\n",PMTI+CMTI); printf("=================================\n"); } //生育保险 void MaternityInsurance() { int b = 1; void CalculateMaternityInsurance(double Pt); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算生育保险\n""2:输入税后工资计算生育保险\n""0:返回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 CalculateMaternityInsurance(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateMaternityInsurance(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //计算住房公积金 void CalculateHousingFund(double Pt) { PHF=Pt*12/100; //计算个人应缴住房公积金金额 CHF=Pt*12/100; //计算单位应缴住房公积金金额 printf("个人应缴住房公积金金额:%.2lf\n",PHF); //输出个人应缴住房公积金金额 printf("个人应缴住房公积金金额:%.2lf\n",CHF); //输出单位应缴住房公积金金额 printf("应缴住房公积金合计是:%.2lf\n",PHF+CHF); printf("=================================\n"); } //住房公积金 void HousingFund() { int b = 1; void CalculateHousingFund(double Pt); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算住房公积金\n""2:输入税后工资计算住房公积金\n""0:回上一级菜单\n"); printf("请输入查询编号:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 CalculateHousingFund(Pt); break; //依据税后工资计算 case 2: PreTaxWages(); CalculateHousingFund(Pt); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //工资计算器 void WageCalculator() { int b = 1; double AfterTaxWages(); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算税后工资\n""2:输入税后工资计算税前工资\n""0:回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: AfterTaxWages(); break; //依据税后工资计算 case 2: PreTaxWages(); printf("税前工资为%.2lf\n",Pt); printf("=================================\n"); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //个人明细打印 void PrintPDuesDetail() { printf("个人应缴养老保险金额:税前收入Pt*0.08= %.2lf\n",Pt*0.08); //输出个人应缴养老保险金额 printf("个人应缴医疗保险金额:税前收入Pt*0.02+3= %.2lf\n",Pt*0.02+3); //输出个人应缴医疗保险金额 printf("个人应缴失业保险金额:税前收入Pt*0.002= %.2lf\n",Pt*0.002); //输出个人应缴失业保险金额 printf("个人应缴工伤保险金额:0\n"); //输出个人应缴工伤保险金额 printf("个人应缴生育保险金额:0\n"); //输出个人应缴生育保险金额 printf("个人应缴住房公积金金额:税前收入Pt*0.12= %.2lf\n",Pt*0.12); //输出个人应缴住房公积金金额 printf("应缴个人所得税是:%.2lf\n",T); //输出个人所得税 printf("个人应缴款合计:%.2lf\n",SH+T); printf("=================================\n"); } //个人应缴明细 void PersonalDuesDetail() { int b = 1; double AfterTaxWages(); void PrintPDuesDetail(); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算明细\n""2:输入税后工资计算明细\n""0:回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: AfterTaxWages(); PrintPDuesDetail(); break; //依据税后工资计算 case 2: PreTaxWages(); SH = (Pt*0.222)+3; //计算个人应缴社保公积金算式 PrintPDuesDetail(); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //打印单位应缴明细 void PrintCDuesDetail() { printf("单位应缴养老保险金额:税前收入Pt*0.19= %.2lf\n",Pt*0.19); //输出单位应缴养老保险金额 printf("单位应缴医疗保险金额:税前收入Pt*0.1=%.2lf\n",Pt*0.1); //输出单位应缴医疗保险金额 printf("单位应缴失业保险金额:税前收入Pt*0.008=%.2lf\n",Pt*0.008); //输出单位应缴失业保险金额 printf("单位应缴工伤保险金额:税前收入Pt*0.005=%.2lf\n",Pt*0.005); //输出单位应缴工伤保险金额 printf("单位应缴生育保险金额:税前收入Pt*0.008=%.2lf\n",Pt*0.008); //输出单位应缴生育保险金额 printf("单位应缴住房公积金金额:税前收入Pt*0.12=%.2lf\n",Pt*0.12); //输出单位应缴住房公积金金额 printf("单位应缴款合计:%.2lf\n",Pt*0.431); printf("=================================\n"); } //单位应缴明细 void CompanyDuesDetail() { int b = 1; void PrintCDuesDetail(); while(b) { //税前税后选择 int a; printf("1:输入税前工资计算明细\n""2:输入税后工资计算明细\n""0:回上一级菜单\n"); printf("请输入查询编号>>>:"); scanf("%d",&a); printf("=================================\n"); switch(a) { //依据税前工资计算 case 1: printf("请输入税前工资:"); scanf("%lf",&Pt); //输入税前工资 PrintCDuesDetail(); break; //依据税后工资计算 case 2: PreTaxWages(); PrintCDuesDetail(); break; //返回主菜单 case 0: b=0;break; default:printf("《《《客官,您输错啦》》》\n");break; } } } //查询函数 void QuerySystem() { int func_num;char choos[20]; void EndowmentInsurance(); void MedicalInsurance(); void UnemploymentInsurance(); void InjuryInsurance(); void MaternityInsurance(); void HousingFund(); void WageCalculator(); void PersonalDuesDetail(); void CompanyDuesDetail(); void InputPreTaxWages(); double PreTaxWages(); while(1) { printf("************************\n"); printf("社会保障体系\n""1:养老保险\n""2:医疗保险\n""3:失业保险\n""4:工伤保险\n""5:生育保险\n""6:住房公积金\n""7:工资计算器\n""8:个人应缴款明细\n""9:单位应缴款明细\n""0:退出当前系统\n"); printf("请输入功能编号:"); scanf("%d",&func_num); printf("************************\n"); switch(func_num) { case 1: printf("欢迎进入养老保险页面\n"); EndowmentInsurance(); break; case 2: printf("欢迎进入医疗保险页面\n"); MedicalInsurance(); break; case 3: printf("欢迎进入失业保险页面\n"); UnemploymentInsurance(); break; case 4: printf("欢迎进入工伤保险页面\n"); InjuryInsurance(); break; case 5: printf("欢迎进入生育保险页面\n"); MaternityInsurance(); break; case 6: printf("欢迎进入住房公积金页面\n"); HousingFund(); break; case 7: printf("欢迎进入工资计算器页面\n"); WageCalculator(); break; case 8: printf("欢迎进入个人应缴明细页面\n"); PersonalDuesDetail(); break; case 9: printf("欢迎进入单位应缴明细页面\n"); CompanyDuesDetail(); break; case 0: printf("退出当前系统:是,否\n"); scanf("%s",&choos); if (strcmp(choos,"是")==0) { exit(0); } else if (strcmp(choos,"否")==0) continue; break; } } } void main() { //登录 int i=0; char user_name[100],passwd[100]; void QuerySystem(); while(i<3) { printf("请输入账户名: "); scanf("%s",&user_name); printf("请输入密码: "); scanf("%s",&passwd); if ((strcmp(user_name,"xiaoming")==0) && (strcmp(passwd,"a123")==0)) { printf("欢迎登录社保工资查询系统\n"); QuerySystem(); break; } else { printf("账号和密码输入有误\n"); } i += 1; } }
原文地址:https://www.cnblogs.com/thoughtful-actors/p/9504924.html
时间: 2024-10-10 15:09:37