1. ## garbage values

Hey all,

I'm trying to write a program that will calculate an employees pay when given the hours worked and the pay rate. I get garbage values for Gross, stateTax, federalTax, FICA, and NetPay.

Code:
void getData (int* emplNum, int* hoursWorked, int* rate);
int calculateGross (int hoursWorked, int rate, int* Gross);
int calcTaxes (int Gross, int* stateTax, int* federalTax);
int calcFICA (int Gross, int* FICA);
int calcNetPay ( int Gross, int stateTax, int federalTax, int FICA, int* NetPay);    //after tax pay
void print_them (int emplNum, int Gross, int stateTax, int federalTax, int FICA, int NetPay);

#include <stdio.h>
int main (void)
{
int emplNum, hoursWorked, rate, Gross, Taxes, NetPay, stateTax, federalTax, FICA;
getData (&emplNum, &hoursWorked, &rate);
Gross = calculateGross (hoursWorked, rate, &Gross);
Taxes = calcTaxes (Gross, &stateTax, &federalTax);
FICA = calcFICA (Gross, &FICA);
NetPay = calcNetPay (Gross, stateTax, federalTax, FICA, &NetPay);
print_them (emplNum, Gross, stateTax, federalTax, FICA, NetPay);
return 0;
}

void getData (int* emplNum, int* hoursWorked, int* rate)
{
printf ("Enter your Employee Number, how many hours you worked (round to the nearest hour), and your pay rate");
scanf ("%d%d%d", emplNum, hoursWorked, rate);
return;
}

int calculateGross (int hoursWorked, int rate, int* Gross)
{
if (hoursWorked <= 40)
*Gross = hoursWorked * rate;
else
*Gross = 40 * rate + (hoursWorked - 40) * 1.5 * rate;
return;
}

int calcTaxes (int Gross, int* stateTax, int* federalTax)
{
*stateTax = .06 * Gross;
if (Gross <= 200)
*federalTax = 0;
else
if ((201 <= Gross) || (Gross <= 300))
*federalTax = .05 * Gross;
else
if ((302 <= Gross) || (Gross <= 350))
*federalTax = .08 * Gross;
else
if ((351 <= Gross) || (Gross <= 400))
*federalTax = .1 * Gross;
else
if (400 < Gross)
*federalTax = .15 * Gross;
else
printf ("Invalid Gross");
return;
}

int calcFICA (int Gross, int* FICA)
{
*FICA = .0707 * Gross;
return;
}

int calcNetPay (int Gross, int stateTaxes, int federalTaxes, int FICA, int* NetPay)
{
*NetPay = Gross - stateTaxes - federalTaxes - FICA;
return;
}

void print_them (int emplNum, int Gross, int stateTax, int federalTax, int FICA, int NetPay)
{
printf ("Employee number: %4d\n", emplNum);
printf ("Gross:  %4d\n", Gross);
printf ("State Tax:  %4d\n", stateTax);
printf ("Federal Tax:  %4d\n", federalTax);
printf ("FICA:  %4d\n", FICA);
printf ("Net Pay:  %4d\n", NetPay);
return;
}

2. Garbage values almost always mean you're using a variable before initializing it. If you compile with warnings on, your compiler will likely tell you as much.

Quzah.

3. I researched a bit about the warning my compiler gave me and figured it out.
Thanks for pointing me in the right direction, quzah!