This method is part of a larger program that pulls employee data from a .txt file and then uses that data to calculate net pay.
My CalcPay method is supposed to figure pay for hours > 40 as well as hours < 40, but when it gets to the employees with more than 40 hours, it figures their pay at just hours * wage as opposed to taking hours > 40 and making them time-and-a-half…any suggestions?
public double CalcPay()
{
double pay = hoursWorked * hourlyWage;
double overTimeHours = hoursWorked - FULL_TIME;
if (overTimeHours > 0)
{
pay += overTimeHours * (hourlyWage * OVER_TIME_RATE);
}
double tax1 = pay * FED_TAX;
double tax2 = pay * STATE_TAX;
return ((pay - tax1) - tax2);
}
I’d probably do something like this.