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
|
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>
using namespace std;
float showrate (char*r);
void getrec ();
void printrec();
void getpayroll ();
void gethours ();
int getmin (char*);
struct{
char*name;
char*id;
char*s;
}emp[5];
{
char*days [5] = {"monday","tuesday","wednesday","thursday","friday"};
int flag =0,x=0,2=0;
}
char * tin = "";
char * tout = "";
char * ptr ="";
float ded = 0, wkhrs = 0;
}
void main (){
FILE * in;
char* employee [5],*ptr
int;
in = f open ("employee.txt "."r");
if (in == NULL)}
{
printf ("error opening file:");
getch ();
exit (0);
}
fseek (in.0, seek_set);
for(1 =0;i,<5;i++)
fgets (employee[.],31,in);
1 - 0;
while (flag<5)
{
ptr = strt ok (employee [.],"//");
emp [x].id = ptr;
ptr = strtok (NULL,"//");
emp [x].s = ptr;
emp [x].rate = showrate (emp[x].s);
x++,i++,flag++;
}
getrec();
fclose();
getch();
}
float showrate (char* r) {
int rt;
rt = atos (r) ;
switch(rt){
case 1: rt = 380 ; break;
case 2: rt = 450 ; break;
case 3: rt = 550 : break;
}
return rt ;
}
void getrec (){
char* ec;
char* ans;
do}
closer ();
print (employee.code);
gets (ec);
flag = 0; x = 0; z = 0;
while (flag<5){
if 9((strcmpi (ec emp [x].id)) = 0){
printf (c"**********************\n");
printf("employee name:%s\n",emp [x].name);
printf("employee code:%s\n",emp [x].id);
printf("salary level: %s\n",emp [x].s)
printf("salary rate: % 0.2f\n",emp [x].rate);
printf("************************\n");
flag = s;
}
}
else{
flag ++; x++;z++;
}
if (3 < 4){
printf ( "no record found");
z = 0;
}
else{
get payroll ();
}
printf ("\n another?[y/n]:");
ans = getch ();
{
while ans ((ans =="y")) ((ans == "y"))
}
void print re() {
printf (c"**********************\n");
printf("employee name:%s\n",emp [x].name);
printf("employee code:%s\n",emp [x].id);
printf("salary level: %s\n",emp [x].s)
printf("salary rate: % 0.2f\n",emp [x].rate);
printf("************************\n");
}
void get payroll () {
float rte, reg;
char* cov;
tre = empp [x] rate ;
gethours ();
reg = (wkhrs*rte)/8;
printrec ();
printf ("enter the coverage date for this payroll:");
gets (cov);
printf ("coverage date : %s\n",cov);
printf ("number of workhours:% 0.1 f\n",wrkhrs);
printf ("salary income:% 0.2 f\n ",reg);
printf ("************************\n");
}
void gethours ()
{
FILE * out;
int y = 0;
int ti = 0,to = 0,hrs = 0;
float m2 =0, m1 = 0;
float late = 0 , under = 0;
out =fopen ("dtr.txt","at");
printf (out,"\n %s",emp[x].id);
while (y/s);
}
|