My program has functions that need to be able to access data from each other. So basically, I need to know where to put the pointers, as much help as you could give me...
Also, my last function is supposed to loop the entire program over again if they answer yes, how do i do this?
thanks for your time.
CODE
#include <stdio.h>
main()
{
get_employee_info();
ltb_calculation();
overtime_rate();
employment_insurance();
canada_pension_plan();
federal_taxes();
output_form();
loop();
}
get_employee_info()
{
int employee_number, gross_pay, week, rate, hours_worked, salary, weekly_salary;
char hourly_salary;
printf ("Please enter your employee number:\n");
scanf ("%d", &employee_number);
printf ("Please enter for which week ending (YYYYMMDD):\n");
scanf ("%d", &week);
getchar();
printf ("Please enter if you are an Hourly (h) or Salary (s) paid employee:\n");
scanf("%c", &hourly_salary);
if( hourly_salary == 'h')
{
printf ("Please enter your rate of pay:\n");
scanf ("%d", &rate);
printf ("Please enter the number of hours worked:\n");
scanf ("%d", &hours_worked);
weekly_salary= rate * hours_worked;
gross_pay= weekly_salary * 52;
}
if (hourly_salary == 's')
{
printf ("Please enter your annual salary:\n");
scanf ("%d", &salary);
weekly_salary= salary/52;
gross_pay= salary;
}
}
ltb_calculation() {
int deduction, ltb;
double grosspay;
if ((grosspay / 100) > 0)
{
ltb= grosspay / 100;
if (ltb > 50)
{
ltb == 50;
}
deduction= ltb * 2;
grosspay= grosspay - deduction;
}
}
overtime_rate()
{
double hourly_salary,overtime_rate, overtime_hours, overtime_pay, grosspay;
double hours, rate;
if (hourly_salary == 'h' && hours > 44)
{overtime_rate= 1.5 * rate;
overtime_hours= hours - 44;
overtime_pay= overtime_hours * overtime_rate;
grosspay= grosspay + overtime_pay;
}
}
employment_insurance()
{
double ei, weekly_salary;
ei= weekly_salary * .014;
if (ei > 11.80)
{
ei= 11.80;
}
}
canada_pension_plan()
{
double deduction, grosspay, pension;
deduction= grosspay * .016;
pension= deduction * 700;
}
federal_taxes()
{
double annual_salary, initial_amount, base_amount, additional_amount;
double remainder_amount, fed_tax, remainder, provincial_tax;
if (annual_salary < 20,000)
{
initial_amount= annual_salary * .16;
}
if (annual_salary >= 20,000)
{
base_amount= 20,000 * .16;
}
remainder= annual_salary - 20,000;
if (remainder >= 20,000)
{
additional_amount= 20,000 * .23;
}
remainder_amount= remainder * .29;
fed_tax= initial_amount + base_amount + additional_amount + remainder_amount;
provincial_tax= fed_tax *.47;
fed_tax= fed_tax + provincial_tax;
}
output_form()
{
char hourly_salary;
double deductions, net_pay, fed_tax, ei, ltb, pension, gross_pay;
int employee_no, week, rate, hours_worked, salary;
deductions= fed_tax + ei + ltb + pension;
net_pay= gross_pay - deductions;
printf ("bob jones Payroll Systems\n");
printf ("102 Orfus Road, Downsview ON\n\n");
printf ("Employee Number:%d For Week Ending:%d, employee_no, week\n\n");
if (hourly_salary == 's')
{
printf ("Salary Paid : %.2d, salary\n\n");
}
if (hourly_salary == 'h')
{
printf ("Hourly Rate: %.2d Hours Worked: %d, rate, hours_worked\n\n"
}
printf("GROSS PAY: %.2d, gross_pay\n\n");
printf ("DEDUCTIONS:\n");
printf ("Long Term Benefits: %.22d, ltb\n");
printf ("Employment Insurance: %.2d, ei\n");
printf ("Canada Pension Plan: %.2d, pension\n");
printf ("Federal Tax: %.2d, fed_tax\n\n");
printf ("TOTAL DEDUCTIONS: %.2d, deductions\n\n");
printf ("NET PAY: %.2d, net_pay\n");
}
loop()
{
char response;
printf ("Would you like to enter more data? ( 'y' or 'n')\n");
getchar();
scanf ("%c", &response);
if (response == 'y')
return 1;
else
return 0;
}