工资信息管理系统.docx
- 文档编号:30009934
- 上传时间:2023-08-04
- 格式:DOCX
- 页数:15
- 大小:17.39KB
工资信息管理系统.docx
《工资信息管理系统.docx》由会员分享,可在线阅读,更多相关《工资信息管理系统.docx(15页珍藏版)》请在冰豆网上搜索。
工资信息管理系统
#include
#include
#include"string.h"
typedefstruct
{
intNum;
charName[20];
intMonth;
intYear;
floatSalary_Total;
floatWater;
floatDianfei;
floatTax;
floatReal_Salary;
}Salary;
SalaryS[200];
intlocation=0;
voidMenu();
floatTax(Salarys)
{
if(s.Salary_Total<=800)
s.Tax=0;
elseif(s.Tax<=1400)
s.Tax=(s.Salary_Total-800)*0.05;
else
s.Tax=(s.Salary_Total-1400)*0.1;
returns.Tax;
}
floatHowMuchSalary(Salarys)
{
s.Real_Salary=s.Salary_Total-s.Dianfei-s.Water-s.Tax;
returns.Real_Salary;
}
voidSearch(SalaryS[])
{
intFindWay,i;
Salaryfind;
printf("\t请选择查询方式:
\n");
printf("\t1.姓名\n");
printf("\t2.卡号\n");
printf("\t你的选择:
");
scanf("%d",&FindWay);
switch(FindWay)
{
case1:
printf("\t请输入姓名:
");
scanf("%s",find.Name);
for(i=0;i { if(strcmp(S[i].Name,find.Name)==0) { printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); break; } } if(i==location) printf("没有找到该员工记录! \n");break; case2: printf("\t请输入卡号: "); scanf("%d",&find.Num); for(i=0;i { if(S[i].Num==find.Num) { printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); break; } } if(i==location) printf("没有找到该员工记录! \n");break; default: { printf("\t输入错误请重新选择! \n"); Search(S); } } } voidInsert(SalaryS[]) { intHowMuch,i; FILE*fp; fp=fopen("Salary.txt","w+"); printf("请输入要插入的员工工资信息数目! \n"); scanf("%d",&HowMuch); printf("输入的信息为: 工资卡号,姓名,月份,年份,应发工资,水费,电费\n"); for(i=location;i { scanf("%d%s%d%d%f%f%f",&S[i].Num,&S[i].Name,&S[i].Month,&S[i].Year,&S[i].Salary_Total,&S[i].Water,&S[i].Dianfei); S[i].Tax=Tax(S[i]); S[i].Real_Salary=HowMuchSalary(S[i]); } location+=HowMuch; fclose(fp); } voidScan(SalaryS[]) { inti; printf("工资卡号姓名月份年份应发工资水费电费税金实发工资\n"); for(i=0;i printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); } voidTotal(SalaryS[]) { intyear,month_from,month_to,i,sumsalary=0; Salarytotal; printf("请输入员工名字: "); scanf("%s",&total.Name); printf("\t请输入时间段! 年月—月"); scanf("%d%d%d",&year,&month_from,&month_to); for(i=0;i { if(strcmp(S[i].Name,total.Name)==0&&S[i].Year==year&&S[i].Month>=month_from&&S[i].Month<=month_to) { sumsalary+=S[i].Real_Salary; printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); } } printf("该员工在指定的时间段内的工资总和为%d元! \n",sumsalary); } voidEdit() { Salaryedit; inti; printf("请输入要修改的员工的姓名和月份: "); scanf("%s%d",&edit.Name,&edit.Month); for(i=0;i { if(strcmp(S[i].Name,edit.Name)==0&&S[i].Month==edit.Month) { printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); printf("卡号: ");scanf("%d",&edit.Num); printf("年份: ");scanf("%d",&edit.Year); printf("月份: ");scanf("%d",&edit.Month); printf("应发工资: ");scanf("%f",&edit.Salary_Total); printf("水费: ");scanf("%f",&edit.Water); printf("电费: ");scanf("%f",&edit.Dianfei); edit.Tax=Tax(edit); edit.Real_Salary=HowMuchSalary(edit); S[i].Dianfei=edit.Dianfei; S[i].Month=edit.Month; strcpy(S[i].Name,edit.Name); S[i].Num=edit.Num; S[i].Real_Salary=edit.Real_Salary; S[i].Salary_Total=edit.Salary_Total; S[i].Tax=edit.Tax; S[i].Water=edit.Water; S[i].Year=edit.Year; printf("修改后的信息如下: ");printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); break; } } if(i==location) printf("没有找到该员工记录! \n"); } voidDelete() { intnum,i,j,Really; printf("请输入工资卡号! \n"); scanf("%d",&num); for(i=0;i { if(S[i].Num==num) { printf("%d%s%d%d%f%f%f%f%f\n", S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); printf("确定删除吗? \n"); printf("1.是\n"); printf("2.否\n"); scanf("%d",&Really); if(Really==1) { if(i for(j=i;j { S[j].Dianfei=S[j+1].Dianfei; S[j].Month=S[j+1].Month; strcpy(S[j].Name,S[j+1].Name); S[j].Num=S[j+1].Num; S[j].Real_Salary=S[j+1].Real_Salary; S[j].Salary_Total=S[j+1].Salary_Total; S[j].Tax=S[j+1].Tax; S[j].Water=S[j+1].Water; S[j].Year=S[j+1].Year; } else { S[j].Dianfei=0; S[j].Month=0; strcpy(S[j].Name,""); S[j].Num=0; S[j].Real_Salary=0; S[j].Salary_Total=0; S[j].Tax=0; S[j].Water=0; S[j].Year=0; } printf("删除成功! \n");location--; } elseif(Really==2) Menu(); else { printf("输入错误! "); Menu(); } break; } } if(i==location) printf("没有找到该员工记录! \n"); } voidOrder(SalaryS[]) { intselect,i,j; Salarytemp; printf("\t请选择排序方式: \n"); printf("\t1.工资卡号\n"); printf("\t2.实发工资\n"); printf("\t你的选择: \n"); scanf("%d",&select); if(select==1) { for(i=0;i for(j=0;j { if(S[j].Num>S[j+1].Num) { temp=S[j]; S[j]=S[j+1]; S[j+1]=temp; } } } elseif(select==2) { for(i=0;i for(j=0;j { if(S[j].Real_Salary { temp=S[j]; S[j]=S[j+1]; S[j+1]=temp; } } } else { printf("输入错误! "); Order(S); } } voidMenu() { intselect; printf("\t请选择操作(输入一个整数): \n"); printf("\t0.退出\n"); printf("\t1.浏览\n"); printf("\t2.查询\n"); printf("\t3.插入\n"); printf("\t4.删除\n"); printf("\t5.修改\n"); printf("\t6.统计\n"); printf("\t7.排序\n"); printf("\t你的选择: "); scanf("%d",&select); switch(select) { case0: exit(0);break; case1: Scan(S);break; case2: Search(S);break; case3: Insert(S);break; case4: Delete();break; case5: Edit();break; case6: Total(S);break; case7: Order(S);break; default: { printf("错误的选择! ! 请重新选择\n"); Menu(); } } } voidmain() { inti,j,Continue; FILE*fp,*Num; Salarytemp; charch; intnum=0; FILE*tr; tr=fopen("ReadMe.txt","a+"); while(ch! =EOF) { ch=fgetc(tr); putchar(ch); } fclose(tr); Num=fopen("Num.txt","a+"); fp=fopen("Salary.txt","a+"); fscanf(Num,"%d",&location); fclose(Num); if(location==0) { printf("没有保存的数据信息! 你可以选择插入添加信息! \n"); } else { for(i=0;i { fscanf(fp,"%d%s%d%d%f%f%f%f%f\n", &S[i].Num,&S[i].Name,&S[i].Month,&S[i].Year,&S[i].Salary_Total,&S[i].Water,&S[i].Dianfei,&S[i].Tax,&S[i].Real_Salary); } printf("上次存储的员工工作信息如下: \n"); Scan(S); } fclose(fp); do { Menu(); printf("\t继续管理该系统吗? \n"); printf("\t1.继续\n"); printf("\telse.退出\n"); printf("\t你的选择: "); scanf("%d",&Continue); }while(Continue==1); Num=fopen("Num.txt","w+"); fp=fopen("Salary.txt","w+"); fprintf(Num,"%d",location); for(i=0;i for(j=0;j { if(S[j].Num>S[j+1].Num) { temp=S[j]; S[j]=S[j+1]; S[j+1]=temp; } } for(i=0;i fprintf(fp,"%d%s%d%d%f%f%f%f%f\n",S[i].Num,S[i].Name,S[i].Month,S[i].Year,S[i].Salary_Total,S[i].Water,S[i].Dianfei,S[i].Tax,S[i].Real_Salary); fclose(fp); fclose(Num); } 【题目设计要求: 】 该系统能够实现工资信息管理。 系统包括录入、浏览、查询、统计等功能。 其中录入功能要求能够添加新的工资信息到文件;浏览功能要求能够按照工资卡号、姓名分类浏览, 提供分屏显示;有排序功能,工资卡号升序或实发工资降序;查询功能要求能够按照工资卡号、姓名 查询;统计功能要求能够按照月份累计统计某职工在某时间段实发工资总金额。 [提示]: 1、文件中一行对应一个职工工资信息 2、采用结构体数组,每个元素对应一个员工工资信息 3、工资信息包括工资卡号、姓名、月份、应发工资、水费、电费、税金、实发工资等。 4、实发工资=应发工资-水费-电费-税金,税金的计算如下 应发工资<=800,税金=0 800<应发工资<1400,税金=(应发工资-800)*5% 应发工资>1400,税金=(应发工资-1400)*10% 【2010/01/18完美完成】
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 工资 信息管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)