#include <stdio.h>
/* Variables*/
struct info
{
char first[30];
char last[30];
};
struct info name[100];
float hours[30];
float rate[30];
int employees,x;
float gross_pay[10];
float fed_tax[10];
float net_pay[10];
float overtime[10];
float temp=0;
float overtime_pay(float hours[], float rate[])
{
temp = hours[x];
overtime[x] = (temp-40)*rate[x]*1.5;
printf("OT $%.2f\n\n",overtime[x]);
return overtime[x];
}
float calculate_tax(float gross_pay[])
{
fed_tax[x] =.2*gross_pay[x] ;
return fed_tax[x];
}
main()
{
printf ("*****WELCOME TO THE PAYROLL CALCULATOR*****\n\n");
for (x = 1; x <=1; ++x)
{
printf("Please enter # of employees(1-10): ");
scanf("%i",&employees);
if (employees > 10)
{ printf ("Invalid Entry\n");
--x;
}
if (employees < 1)
{ printf ("Invalid Entry\n");
--x;
}
}
for (x = 1; x <=employees; ++x)
{
printf ("\nEnter first and last name of employee%i: ",x);
scanf("%s %s",name[x].first, name[x].last);
printf("Enter pay rate for employee %i: ",x);
scanf("%f", &rate[x]);
printf("Enter hours worked for employee %i: ",x);
scanf("%f", &hours[x]);
if(hours[x] > 40)
{overtime_pay(hours, rate);
}
}
for (x = 1; x <= employees; ++x)
{ gross_pay[x]=hours[x]*rate[x]+overtime[x];
printf("GROSS%i: %.2f\n",x, gross_pay[x]);
calculate_tax(gross_pay);
printf("TAX%i: %.2f\n",x, fed_tax[x]);
net_pay[x]=gross_pay[x]-fed_tax[x];
printf("NET%i: %.2f\n\n",x, net_pay[x]);
}
}
Edited by WingedPanther, 13 February 2009 - 04:58 PM.
add code


Sign In
Create Account

Back to top









