课程设计目的和要求
工资管理要和人事管理相联系,生成企业每个职工的实际发放工资。
企业职工人事基本信息包括:职工编号、姓名、性别、出生日期、职称(助工、工程师、高级工程师)和任职年限。
企业职工工资信息包括:职工编号、姓名、职务工资、职务补贴、住房补贴、应发工资、个人所得税、养老保险、住房公积金和实发工资。
系统主要功能包括:
(1)创建职工人事基本信息文件,根据提示输入职工的各项信息,按职工编号对职工信息进行排序,并将排序后的职工信息存储到一个文件中。
(2)创建职工的工资信息文件(每个月创建一个文件),其中职工编号和姓名从人事信息文件中复制,其他工资组成项目按下面方法计算。
职务工资:助工=1270*(1+任职年限*2%)
工程师=2360*(1+任职年限*3%)
高级工程师=3450*(1+任职年限*5%)
职务补贴:=职务工资*25%
住房补贴=(职务工资+职务补贴)*15%
应发工资=职务工资+职务补贴+住房补贴
个人所得税=(应发工资-3000)*5%
养老保险=(职务工资+职务补贴)*10%
住房公积金=应发工资*5%
实发工资=应发工资-个人所得税-养老保险-住房公积金
(3)增加职工人事基本信息,在原有职工人事基本信息文件的基础上增加新有的职工信息。
(4)删除职工人事基本信息,提示用户输入要删除的职工编号,如果在文件有该信息存在,则将其信息输出到屏幕上,用户确认后将该信息删除,并将删除后的结果保存至原文件。最后提示用户是否继续进行删除操作。
(5)修改职工人事基本信息,提示用户输入要删除的职工编号,如果在文件有该信息存在,则将其信息输出到屏幕上,然后提示用户要修改的选项(职称、任职年限),并将修改后的结果保存至原文件。最后提示用户是否继续进行修改操作。
(6)按不同条件进行查询操作,输出满足条件的职工工资信息。
① 按职工编号查询,输入一个编号,输出对应职工工资信息。
② 按姓名查询,包括精确查询,模糊查询。
③ 按职称查询,输入职称名称,输出相应职称工资信息。
(7)按不同条件对职工工资信息进行统计工作。
① 统计个职称岗位的职工人数是多少,计算高级工程师比例。
② 计算企业职工的平均实发工资,并输出。
③ 统计职工工资低于平均工资人数,并输出他们的姓名和实发工资。
代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
#include<stdafx.h> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<conio.h> #include<time.h> typedef struct date { short year; short month; short day; }st3; typedef struct gerenxinxi { char num[30]; char name[30]; char sex[30]; st3 chushengriqi; char zhicheng[20]; int nianxian; }st; typedef struct gerengongzi { char num[20]; char name[12]; double zhiwugongzi; double zhiwubutie; double zhufangbutie; double yingfagongzi; double gerensuodeshui; double yanglaobaoxian; double zhufanggongjijin; double shifagongzi; }st1; #define st3_len sizeof(st3) #define st_len sizeof(st) #define st1_len sizeof(st1) #define gerenxinxinum 1000 #define gerengongzinum 1000 st gerenxinxi[gerenxinxinum]={0}; st1 gerengongzi[gerengongzinum]={0}; int loadgerenxinxi( void ); //将文件中的信息读取 int originalgerenxinxi( void ); //个人信息初始化 void getonegerenxinxi( int i); //输ru一个职工的个人信息 void allgerenxinxi( int bn); //保存所有信息 void xggerenxinxi( int bn); //修改个人信息 void saveonegerenxinxi( int i); //保存个人信息 int addgerenxinxi( int bn); //增加个人信息 int delgerenxinxi( int bn); //删除个人信息 void putonegerenxinxi( int i); //输出一个个人信息 void sort( int bn); //排序 void shengchenggongzi( int bn); //生成工资 void putonegerengongzi( int i); //输出一个人的工资信息 void cxgerenxinxi( int bn); //查询 void cxzhicheng( int bn); //职称查询 void cxname( int bn); //姓名查询 void cxnum( int bn); //编号查询 void tongjigongzixinxi( int bn); //统计工资信息 float avegongzi( int bn); //平均工资 void lowgongzi( int bn); //低于平均工资 void gangweirenshu( int bn); //职工人数 void main() { int select,bn; bn=loadgerenxinxi(); if (bn==0) printf ( "职工信息为零:" ); while (1) { printf ( "\n 企业职工工资管理系统 \n" ); printf ( "\n-----------------------------\n" ); printf ( "\n 请输入要进行操作前的序号 \n" ); printf ( "\n 1.输入职工信息 \n" ); printf ( "\n 2.修改职工信息 \n" ); printf ( "\n 3.增加职工信息 \n" ); printf ( "\n 4.删除职工信息 \n" ); printf ( "\n 5.职工工资 \n" ); printf ( "\n 6.统计工资信息 \n" ); printf ( "\n 7.查询工资信息 \n" ); printf ( "\n 0.退出 \n" ); printf ( "\n----------------------------\n" ); scanf ( "%d" ,&select); getchar (); switch (select) { case 1: originalgerenxinxi(); break ; case 2: xggerenxinxi(bn); break ; case 3: addgerenxinxi(bn); break ; case 4: delgerenxinxi(bn); break ; case 5: shengchenggongzi(bn); break ; case 6: tongjigongzixinxi(bn); break ; case 7: cxgerenxinxi(bn); break ; case 0: return ; default : printf ( "\n按键错误,请重新选择\n" ); } } } //===================================================== int loadgerenxinxi( void ) //将文件中的信息读取 { FILE *fb; int bn=0; if ((fb= fopen ( "gerenxinxi.txt" , "r+" ))==NULL) { printf ( "不能打开\n" ); return (bn); } while (! feof (fb)) if ( fread (&gerenxinxi[bn],st_len,1,fb)) bn++; fclose (fb); return (bn); } //====================================================== int originalgerenxinxi( void ) //个人信息初始化 { int n; char c= 'y' ; for (n=0;c== 'y' ;n++) { printf ( "\n输入职工%d的信息:\n" ,n+1); getonegerenxinxi(n); printf ( "\n继续输入请按'y',停止请按'n':" ); c= getchar (); getchar (); } sort(n); allgerenxinxi(n); return (n); } //====================================================== void getonegerenxinxi( int i) //输ru一个职工的个人信息 { printf ( "职工编号:" ); gets (gerenxinxi[i].num); printf ( "姓名:" ); gets (gerenxinxi[i].name); printf ( "性别:" ); gets (gerenxinxi[i].sex); printf ( "出生日期:" ); scanf ( "%d.%d.%d" ,&gerenxinxi[i].chushengriqi.year,&gerenxinxi[i].chushengriqi.month,&gerenxinxi[i].chushengriqi.day); getchar (); printf ( "职称(助工,工程师 ,高级工程师):" ); gets (gerenxinxi[i].zhicheng); printf ( "任职年限:" ); scanf ( "%d" ,&gerenxinxi[i].nianxian); getchar (); } //====================================================== void allgerenxinxi( int bn) //保存所有信息 { FILE *fb; if ((fb= fopen ( "gerenxinxi.txt" , "w" ))==NULL) { printf ( "不能打开\n" ); exit (1); } fwrite (gerenxinxi,st_len,bn,fb); fclose (fb); } //======================================================= void xggerenxinxi( int bn) //修改个人信息 { int select,k=-1; char number[20],c1= 'y' ,c2; if (bn==0) { printf ( "\n职工信息为空\n:" ); return ; } while (c1== 'y' ) {c2= 'y' ; printf ( "\n请输入要修改的职工编号\n" ); gets (number); for ( int i=0;i<bn;i++) if ( strcmp (gerenxinxi[i].num,number)==0) { k=i; break ;} if (k<0) printf ( "\n编号有误,请重新输入\n" ); else { printf ( "\n职工信息:\n" ); putonegerenxinxi(k); while (c2== 'y' ) { printf ( "\n请输入要修改项前的序号:\n" ); printf ( "1.职称\n" ); printf ( "2.任职年限\n" ); printf ( "0.退出程序\n" ); scanf ( "%d" ,&select); getchar (); switch (select) { case 1: printf ( "职称:" ); gets (gerenxinxi[k].zhicheng); break ; case 2: printf ( "入职年限:" ); scanf ( "%d" ,&gerenxinxi[k].nianxian); getchar (); break ; case 0: exit (1); default : printf ( "\n按键错误,请重新输入\n" ); } printf ( "\n还要修改该职工其它信息吗(y/n)?\n" ); c2= getchar (); getchar (); } } saveonegerenxinxi(k); printf ( "\n还要修改其他职工信息吗?(y/n)\n" ); c1= getchar (); getchar (); } printf ( "\n按任意键继续\n" ); getchar (); } //====================================================== void saveonegerenxinxi( int i) //保存个人信息 { FILE *fb; if ((fb= fopen ( "gerenxinxi.txt" , "r+" ))==NULL) { printf ( "不能打开 \n" ); exit (1); } fseek (fb,st_len*i,0); fwrite (&gerenxinxi[i],st_len,1,fb); fclose (fb); } //====================================================== int addgerenxinxi( int bn) //增加个人信息 { char c= 'y' ; FILE *fb; if ((fb= fopen ( "gerenxinxi.txt" , "a" ))==NULL) { printf ( "不能打开\n" ); exit (1); } while (c== 'y' ) { printf ( "\n请输入新增职工信息:\n" ); getonegerenxinxi(bn); fwrite (&gerenxinxi[bn],st_len,1,fb); bn++; printf ( "\n继续输入其他职工信息吗?(y/n):" ); c= getchar (); getchar (); } printf ( "\n按任意键继续\n:" ); getch(); fclose (fb); return (bn); } //====================================================== int delgerenxinxi( int bn) //删除个人信息 { int k=-1; char number[20],c1= 'y' ,c2; if (bn==0) { printf ( "\n信息为空\n" ); return (bn); } while (c1== 'y' ) { c2= 'y' ; printf ( "\n输入要删除的职工编号\n" ); gets (number); for ( int i=0;i<bn;i++) if ( strcmp (gerenxinxi[i].num,number)==0) { k=i; break ;} if (k<0) printf ( "\n编号有误,重新输入\n" ); else { printf ( "\n职工信息:\n" ); putonegerenxinxi(k); printf ( "\n确定要删除该职工的全部信息吗?(y/n):" ); c2= getchar (); getchar (); if (c2== 'y' ) { for (i=k;i<bn;i++) gerenxinxi[i]=gerenxinxi[i+1]; bn--; printf ( "\n成功删除!\n" ); } else printf ( "\n取消删除!\n" ); printf ( "\n继续删除其它职工信息吗?(y/n):" ); c1= getchar (); getchar (); } } allgerenxinxi(bn); printf ( "\n按任意键继续!\n" ); getch(); return (bn); } //==================================================== void putonegerenxinxi( int i) //输出一个个人信息 { printf ( "\n" ); printf ( "职工编号:" ); puts (gerenxinxi[i].num); printf ( "姓名:" ); puts (gerenxinxi[i].name); printf ( "性别:" ); puts (gerenxinxi[i].sex); printf ( "出生日期:" ); printf ( "%d.%d.%d\n" ,gerenxinxi[i].chushengriqi.year,gerenxinxi[i].chushengriqi.month,gerenxinxi[i].chushengriqi.day); printf ( "职称:" ); puts (gerenxinxi[i].zhicheng); printf ( "任职年限:" ); printf ( "%d" ,gerenxinxi[i].nianxian); } //================================================== void sort( int bn) //排序 { st temp; int i,j; for (i=0;i<bn-1;i++); { for (j=i+1;j<bn;j++) if (gerenxinxi[i].num >gerenxinxi[i+1].num ) { temp=gerenxinxi[i]; gerenxinxi[i]=gerenxinxi[i+1]; gerenxinxi[i+1]=temp; } } } //================================================= void shengchenggongzi( int bn) //生成工资 { FILE *fp,*fp2; int i,j; if ((fp = fopen ( "gerenxinxi.txt" , "r" )) == NULL) { printf ( "不能打开\n" ); exit (0); } fread (gerenxinxi,st_len,bn, fp); if ((fp2 = fopen ( "gerengongzi.txt" , "w" )) == NULL) { printf ( "不能打开\n" ); exit (0); } for (i=0;i<bn;i++) { strcpy (gerengongzi[i].name, gerenxinxi[i].name); strcpy (gerengongzi[i].num, gerenxinxi[i].num); if ( strcmp (gerenxinxi[i].zhicheng, "助工" ) == 0) {gerengongzi[i].zhiwugongzi=1270*(1+gerenxinxi[i].nianxian*0.02);} if ( strcmp (gerenxinxi[i].zhicheng, "工程师" ) == 0) {gerengongzi[i].zhiwugongzi=2360*(1+gerenxinxi[i].nianxian*0.03);} if ( strcmp (gerenxinxi[i].zhicheng, "高级工程师" ) == 0) {gerengongzi[i].zhiwugongzi=3450*(1+gerenxinxi[i].nianxian*0.05);} gerengongzi[i].zhiwubutie=gerengongzi[i].zhiwugongzi*0.25; gerengongzi[i].zhufangbutie=(gerengongzi[i].zhiwubutie+gerengongzi[i].zhiwugongzi)*0.15; gerengongzi[i].yingfagongzi=gerengongzi[i].zhiwugongzi+gerengongzi[i].zhiwubutie+gerengongzi[i].zhufangbutie; if (gerengongzi[i].yingfagongzi>3000) gerengongzi[i].gerensuodeshui=(gerengongzi[i].yingfagongzi-3000)*0.05; else gerengongzi[i].gerensuodeshui=0; gerengongzi[i].yanglaobaoxian=(gerengongzi[i].zhiwubutie+gerengongzi[i].zhiwugongzi)*0.1; gerengongzi[i].zhufanggongjijin=gerengongzi[i].yingfagongzi*0.05; gerengongzi[i].shifagongzi=gerengongzi[i].yingfagongzi-gerengongzi[i].gerensuodeshui-gerengongzi[i].yanglaobaoxian-gerengongzi[i].zhufanggongjijin; } printf ( "\n" ); fwrite (gerengongzi,st1_len,bn,fp2); fclose (fp); fclose (fp2); if ((fp = fopen ( "gerengongzi.txt" , "r+" )) == NULL) { printf ( "不能打开\n" ); exit (1); } fread (gerengongzi,st1_len,bn,fp2); for (j=0;j<bn;j++) putonegerengongzi(j); fclose (fp); } //========================================================== void putonegerengongzi( int i) //输出一个人的工资信息 { printf ( "\n" ); printf ( "职工编号:" ); puts (gerengongzi[i].num); printf ( "职工姓名:" ); puts (gerengongzi[i].name); printf ( "劳务工资:" ); printf ( "%f\n" ,gerengongzi[i].zhiwugongzi); printf ( "劳务补助:" ); printf ( "%f\n" ,gerengongzi[i].zhiwubutie); printf ( "住房补贴:" ); printf ( "%f\n" ,gerengongzi[i].zhufangbutie); printf ( "应发工资:" ); printf ( "%f\n" ,gerengongzi[i].yingfagongzi); printf ( "个人所得税:" ); printf ( "%f\n" ,gerengongzi[i].gerensuodeshui); printf ( "养老保险:" ); printf ( "%f\n" ,gerengongzi[i].yanglaobaoxian); printf ( "住房公积金:" ); printf ( "%f\n" ,gerengongzi[i].zhufanggongjijin); printf ( "实发工资:" ); printf ( "%f\n" ,gerengongzi[i].shifagongzi); } //=============================================== void cxgerenxinxi( int bn) //查询 { int select; while (1) { printf ( "\n请输入要进行操作前的编号\n" ); printf ( "1.编号查询\n" ); printf ( "2.按姓名查询\n" ); printf ( "3.按职称查询\n" ); printf ( "0.退出查询\n" ); scanf ( "%d" ,&select); getchar (); switch (select) { case 1: cxnum(bn); break ; case 2: cxname(bn); break ; case 3: cxzhicheng(bn); break ; case 0: return ; default : printf ( "\n按键错误,请重新选择\n" ); } } } //============================================== void cxnum( int bn) { int i; char number[20],c= 'y' ; while (c== 'y' ) { printf ( "\n请输入职工编号:" ); gets (number); for (i=0;i<bn;i++) if ( strcmp (gerenxinxi[i].num,number)==0) { printf ( "\n职工%d的信息:\n" ); putonegerenxinxi(i); printf ( "\n按任意键继续!\n" ); getch(); } if (i==bn) printf ( "\n没有找到职工信息\n" ); return ; } printf ( "\n按任意键继续查询!\n" ); getchar (); } //================================================ void cxzhicheng( int bn) { int i; char zhicheng[20],c= 'y' ; while (c== 'y' ) { printf ( "\n请输入职工职称:" ); gets (zhicheng); for (i=0;i<bn;i++) if ( strcmp (gerenxinxi[i].zhicheng,zhicheng)==0) { printf ( "\n职工的信息:\n" ); putonegerenxinxi(i); printf ( "\n按任意键继续!\n" ); getch(); } if (i==bn) { printf ( "\n没有找到职工信息\n" ); return ; } } printf ( "\n按任意键继续查询!\n" ); getchar (); } //============================================== void cxname( int bn) //姓名查询 { int i,j,k; char name[12],c= 'y' ; while (c== 'y' ) { k=-1; printf ( "\n请输入职工姓名:" ); gets (name); for (i=0,j=1;i<bn;i++) if ( strcmp (gerenxinxi[i].name,name)==0) { printf ( "\n当前为准确查询\n" ); k=i; printf ( "\n职工%d的信息:\n" ,j++); putonegerenxinxi(k); printf ( "\n按任意键继续!\n" ); getch(); } if (k==-1) { printf ( "\n当前为模糊查询\n" ); for (i=0,j=1;i<bn;i++) if ( strstr (gerenxinxi[i].name,name)!=NULL) { k=i; printf ( "\n职工%d的信息:\n" ,j++); putonegerenxinxi(k); printf ( "\n按任意键继续!\n" ); getch(); } if (j==1) printf ( "\n没有找到职工信息!\n" ); return ; } } printf ( "\n按任意键继续!\n" ); getchar (); } //================================================= void tongjigongzixinxi( int bn) //统计工资信息 { int select; while (1) { printf ( "请输入要进行操作前的编号\n" ); printf ( " 1.各职称岗位的职工人数\n" ); printf ( " 2.职工的平均实发工资\n" ); printf ( " 3.低于平均工资的人数\n" ); printf ( " 0.退出统计功能\n" ); scanf ( "%d" ,&select); getchar (); switch (select) { case 1:gangweirenshu(bn); break ; case 2:avegongzi(bn); break ; case 3:lowgongzi(bn); break ; case 0: return ; default : printf ( "\n按键错误,请重新选择!\n" ); } return ; } } //================================================= void gangweirenshu( int bn) //职工人数 { int i,j=0, k=0, m=0; float ave; for (i=0;i<bn;i++) { if ( strcmp (gerenxinxi[i].zhicheng , "助工" )==0) j++; if ( strcmp (gerenxinxi[i].zhicheng , "工程师" )==0) k++; if ( strcmp (gerenxinxi[i].zhicheng , "高级工程师" )==0) m++; } ave=(m*1.0/bn); printf ( "助工人数为%d人\n" ,j); printf ( "工程师人数为%d人\n" ,k); printf ( "高级工程师人数为%d人\n" ,m); printf ( "高级工程师比例为%f\n" ,ave); } //================================================== float avegongzi( int bn) //平均工资 { int i; float sum=0; float ave; for (i=0;i<bn;i++) sum=sum+gerengongzi[i].shifagongzi; ave=(sum/bn); printf ( "职工的平均实发工资为:%f\n" ,ave); return (ave); return (0); } //================================ void lowgongzi( int bn) //低于平均工资 { int i,k=0; float b; b=avegongzi(bn); for (i=0;i<bn;i++) { if (gerengongzi[i].shifagongzi<b) { k++; printf ( "姓名:%s\n" ,gerengongzi[i].name); printf ( "工资:%f\n" ,gerengongzi[i].shifagongzi); } } printf ( "低于平均工资的人数为:%d\n" ,k); } |
努力了一个多星期,自己头一次做这么大的程序,鼓励一下
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/zero_bug/article/details/42553139