#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
FILE *fp1, *fp2;
int count;
struct record
{
char name[20];
int empnum;
char depart[20];
float hours;
float rate;
};
void main()
{
clrscr();
record h;
int acount=0,adcount=0,scount=0;
float grosspay,totalg=0;
float tax,totalt=0;
float health,totalh=0;
float pension,totalp=0;
float netpay,totaln=0;
float deductions;
fp1=fopen("employ.dat","r");
fp2=fopen("payrol.dat","w");
count = 0;
printf(" ""Page1\n");
printf(" ""ABC COMPANY EMPLOYEE REPORT""\n");
printf("------------------------------------------\n");
printf("%5s %20s %10s %12s %5s %10s %9s %7s\n","Name","Empnumber","Depart","Tax","Health","Pension","Netpay");
printf("___________________________________________________________________________________\n");
while(fread(&h,sizeof(struct record),1,fp1)==1)
{
grosspay=h.hours*h.rate;
tax = 0.155 * grosspay;
pension=0.03*grosspay;
deductions=(tax+health+pension);
netpay=grosspay-deductions;
totalg=totalg+grosspay;
totalt=totalt+tax;
totalh=totalp+pension;
totaln=totaln+netpay;
printf("%2s\t %5d\t %10s\t %4.2f\t %4.2f\t %4.2f\t %4.2f\t %4.2f\n",h.name,h.empnum,h.depart,grosspay,tax,health,pension,netpay);
if(strcmp(h.depart,"Sales")==0
scount=scount+1;
else if(strcmp(h.depart,"Admin")==0)
adcount=adcount+1;
else
acount=acount+1;
count++;
}
printf("__________________________________________\n");
printf("TOTALS %4.2f\t %4.2\t %4.2f\t %4.2f\t %4.2f\n",totalg,totalt,totalh,totalp,totaln);
printf("Total Number From Sales Department:%d\n",scount);
printf("Total Number From Sales Department:%d\n",scount);
printf("Total Number From Admin Department:%d\n",adcount);
printf("Total Number From Accounts Department:%d\n",&acount);
printf("Total Number Of Employees:%d\n",count);
fwrite(&h,sizeof(h),1,fp2);
fflush(stdin);
fclose(fp1);
fclose(fp2);
}
tendekai 0 Newbie Poster
Dave Sinkula 2,398 long time no c Team Colleague
ZuK 0 Light Poster
tendekai 0 Newbie Poster
Dave Sinkula 2,398 long time no c Team Colleague
Narue 5,707 Bad Cop Team Colleague
tendekai 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.