当前位置:编程学习 > C/C++ >>

用C语言如何设计工资管理系统

要求:

职工基本信息:如工资卡号、身份证号、姓名、性别、年龄、工龄、部门、技术职称、技术职称编号、家庭电话号码、手机号码等。

工资基础信息:技术职称编号、技术职称、基本工资、职务工资、各种补助等。

费用扣除信息:工资卡号、水费、电费等。

工资单数据:工资卡号、姓名、应发工资、水费、电费、税金、实发工资、特别奖励。其中:税金计算方法为:

应发工资<=1200元,税金=0;

1200<应发工资<=1600元,税金=(应发工资-1200)*5%

应发工资>1600元,税金=(应发工资-1600)*10% +400*5%

功能性要求:1.系统菜单

2.基础数据输入,修改

3.基础数据查找

4.复合数据查找
5.计算统计

答案:#include<string.h> 
void menu()
{
int n,w1;
do
{
printf("\t\t************************************************\n\n");
printf("\t\t************************************************\n\n");

printf("\t\t *** choose function ************\n\n");
printf("\t\t *** 1 Enter new data ************\n\n");
printf("\t\t *** 2 Modify data ************\n\n");
printf("\t\t *** 3 Search by people.xueli and num*****\n\n");
printf("\t\t *** 4 Browse data ************\n\n");
printf("\t\t *** 5 add data ************\n\n");
printf("\t\t *** 6 Exit ************\n\n");
printf("\t\t************************************************\n\n");
printf("\t\t************************************************\n\n");
printf("Choose your number(1-6):[ ]\b\b");
scanf("%d",&n);
if(n<1||n>6)
w1=1;
else w1=0;
}
while(w1==1);
switch(n)
{
case 1:enter();break;
case 2:modify();break;
case 3:search();break;
case 4:browse();break;
case 5:add();break;
case 6:exit(0);
}
}

main()
{
system("cls");
menu();
}

#define N 100
struct people
{
char num[100];
char name[15];
char 易做图[20];
char age[20];
char xueli[20];
char gongzhi[20];
char address[20];
char telephone[20];
}people[N];


# include <stdio.h>


enter()
{
int i,n;
printf("How many people(0-%d)?:",N-1);
scanf("%d",&n);
printf("\n Enter data now\n\n");
for(i=0;i<n;i++)
{
printf("\n Input %dth people record.\n",i+1);
input(i);
}
if(i!=0)save(n);
printf_back();
}


browse()
{
int i,j,n;
n=load();
printf_face();
for(i=0;i<n;i++)
{
if((i!=0)&&(i%10==0))
{
printf("\n\nPass any key to continue ....");
getch();
puts("\n\n");
}
printf_one(i) ;
}
printf("\tThere are %d record.\n",n);
printf("\nPass any key to back ...");
getch();
menu();
}


add()
{
int i,n,m,k;
FILE*fp;
n=load();
printf("How many people are you want to add(0-%d)?:",N-1-n);
scanf("%d",&m);
k=m+n;
for(i=n;i<k;i++)
{
printf("\nInput %dth people record.\n",i-n+1 );
input(i);
}
if((fp=fopen("Pro.txt","ab"))==NULL)
{
printf("cannot open file\n");
}
for(i=n;i<k;i++)
if(fwrite(&people[i],sizeof(struct people),1,fp)!=1)
printf("file write error\n");
fclose(fp);
printf_back();
}


search()
{
int i,n,k,w1=1,w2,w3,w4,m,a;
struct people p;
n=load();
do
{
printf("\n\nWhich way do you want to choose? \n\t1).By xueli 2).By num [ ]\b\b");
scanf("%d",&m);
switch(m)
{
case 1:
do
{ k=-1;
printf("\n\nEnter xeuli that you want to search! xueli.");
scanf("%s",p.xueli);
printf_face();
for(i=0;i<n;i++)
if(strcmp(p.xueli,people[i].xueli)==0)
{ k=i;
printf_one(k);break;
}
if(k==-1)
{ printf("\n\nNO exist!please");
printf("\n\nAre you again?\n\t1).again 2).NO and back [ ]\b\b");
scanf("%d",&w1);
if(w1==2)
printf_back();
}
}
while(k==-1&&w1==1);break;
case 2:
do
{k=-1;
printf("\n\nEnter num that you want to search! num.");
scanf("%s",p.num);
printf_face();
for(i=0;i<n;i++)
if(strcmp(p.num,people[i].num)==0)
{k=i;
printf_one(k);break;
}
if(k==-1)
{printf("\n\nNO exist!please");
printf("\n\nAre you again?\n\t1).again 2).NO and back [ ]\b\b");
scanf("%d",&w1);
if(w1==2)
printf_back();
}
}
while(k==-1&&w1==1);break;
}
w4=0;w3=0;
if(k!=-1)
{printf("\n\nWhat do you want to do?\n\t 1).Search 2).Modify 3).Delete 4).Back menu [ ]\b\b");
scanf("%d",&w2);
switch(w2)
{case 2:w3=modify_data(k,n);break;
case 3:{printf("\nAre you sure?\n\t 1).Sure 2).No and back [ ]\b\b");
scanf("%d",&w4);
if(w4==1)
for(a=k;a<n;a++)
{strcpy(people[a].num,people[a+1].num);
strcpy(people[a].name,people[a+1].name);
strcpy(people[a].易做图,people[a+1].易做图);
strcpy(people[a].age,people[a+1].age);
strcpy(people[a].xueli,people[a+1].xueli);
strcpy(people[a].gongzhi,people[a+1].gongzhi);
strcpy(people[a].address,people[a+1].address);
strcpy(people[a].telephone,people[a+1].telephone);

}

break;
}
}
if(w3==1||w4==1)
{save(n);
printf("\n\nSuccessful.^_^.");
printf("\n\nWhant do you want to do? \n\t 1).Search another 2).Back [ ]\b\b" );
scanf("%d",&w2);
}
}
}
while(w2==1);
menu();
}


modify()
{struct people p;
FILE *fp;
int i,n,k,w0=1,w1,w2=0;
n=load();
do
{
k=-1;
printf_face();
for(i=0;i<n;i++)
{if((i!=0)&&(i%10==0))
{printf("\n\nRemember NO.which needed modify.pass any key to contiune ...");
getch();
puts("\n\n");
}
printf_one(i);
}
do
{printf("\n\nEnter NO.that you want to modify! NO.:");
scanf("%s",p.num);
for(i=0;i<n;i++)
if(strcmp(p.num,people[i].num)==0)
{k=i;
p=people[i];
}
if(k==-1)printf("\n\nNO exist!please again");
}while(k==-1);
printf_face();
printf_one(k);
w1=modify_data(k,n);
if(w1==1)
{printf("\nSuccessful ^_^.\n\nAre you modify another ?\n\n\t 1).Yes 2).Back with save\t[ ]\b\b");
scanf("%d",&w0);
w2=1;
}
else
{w0=0;
if(w2==1)
people[k]=p;
}
if(w0!=1&&w2==1)
save(n);
}while(w0==1);
menu();
}


save(int n)
{FILE *fp;
int i;
if((fp=fopen("Pro.txt","wb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;i<n;i++)
if(people[i].num!=0)
if(fwrite(&people[i],sizeof(struct people),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}



load()
{FILE *fp;
int i;
if((fp=fopen("Pro.txt","rb"))==NULL)
{printf("\nCannot open file\n");
return NULL;
}
for(i=0;!feof(fp);i++)
fread(&people[i],sizeof(struct people),1,fp);
fclose(fp);
return(i-1);
}


input(int i)
{
no_input(i,i);
printf("num:");
scanf("%s",people[i].num);
printf("name:");
scanf("%s", people[i].name) ;
printf("易做图:");
scanf("%s",people[i].易做图);
printf("age:");
scanf("%s",people[i].age);
printf("xueli:");
scanf("%s",people[i].xueli);
printf("gongzhi:");
scanf("%s",people[i].gongzhi);
printf("address:");
scanf("%s",people[i].address);
printf("telephone:");
scanf("%s",people[i].telephone);
}


modify_data(int i)
{int c,w1;
do
{puts("\nmodify by=>\n\n 1).num 2).name 3).易做图 4).ages 5).xueli 6)gongzhi 7)address 8)telephone ");
printf("Which you needed?:[ ]\b\b");
scanf("%d",&c);
if(c>8||c<1)
{puts("\nChoice error!Please again!");
getchar();
}
}while(c>8||c<1);
do
{switch(c)
{
case 1:printf("num:");scanf("%s",people[i].num);break;
case 2:printf("name:");scanf("%s",people[i].name);break;
case 3:printf("易做图:");scanf("%s",people[i].易做图);break;
case 4:printf("age:");scanf("%s",people[i].age);break;
case 5:printf("xueli:");scanf("%s",people[i].xueli);break;
case 6:printf("gongzhi:");scanf("%s",people[i].gongzhi);break;
case 7:printf("address:");scanf("%s",people[i].address);break;
case 8:printf("telephone:");scanf("%s",people[i].telephone);break;
}
puts("\nNow:\n");
printf_face();
printf_one(i);
printf("\nAre you sure?\n\n\t 1).Sure 2).No and remodify 3).Back without save in this time [ ]\b\b");
scanf("%d",&w1);
}
while(w1==2);
return(w1);
}


no_input(int i,int n)
{int j,k,w1;
do
{w1=0;

for(j=0;p

上一个:计算机C语言过级怎样考试
下一个:C语言已经取代了汇编语言吗?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,