I will admit that this is homework. I am currently taking a 6 week C Programming class at a community college. I was really hung up and stuck on arrays when I was assigned this. Now it is late and I just want to get it done. I really want to learn C. But I also want to pass this class. I wrote the original code; now I just need to modify it. Please help!!
Write a method that prompts the user for hours worked, rate and name. Use parameter passing, and pass by reference.
Write a method that calculates the gross, base and overtime pay, pass by reference.
Write a method that calculates tax, taking as input the gross pay, returning the tax owed.
Calculate the total amount paid (gross pay) for all 5 people. Use the return value from the method that calculates the gross pay.
Write a print method that generates the output, including the total amount paid, in addition to the data for each employee.
#include
main()
{
char name[25];
float rate = 0;
float hours = 0;
float basePay = 0;
float overTime = 0;
float grossPay = 0;
float netPay = 0;
int i;
for(i = 0; i < 5; i++) { printf("\nWhat is your name? "); scanf("%s", &name); printf("\nHow much is your hourly pay? "); scanf("%f", &rate); printf("\nHow many hours did you work this week? "); scanf("%f", &hours); basePay = rate * hours; grossPay = rate * 40 + (basePay - overTime); overTime = (basePay - (1.5 * rate)); netPay = grossPay - (0.20 * grossPay); if (hours > 40){
printf(“\nPay for %s\n”, name);
printf(“\nHourly rate:\t $%.2f\n”, rate);
printf(“\nHours worked:\t $%.2f\n”, hours);
printf(“\nGross pay:\t $%.2f\n”, grossPay);
printf(“\nTaxes paid:\t $%.2f\n”, 0.20 * grossPay);
printf(“\nBase pay:\t $%.2f\n”, basePay);
printf(“\nOvertime pay:\t $%.2f\n”, overTime);
printf(“\nNet pay:\t $%.2f\n”, netPay);
}
else {
printf(“\nPay for %s\n”, name);
printf(“\nHourly rate:\t $%.2f\n”, rate);
printf(“\nHours worked:\t $%.2f\n”, hours);
printf(“\nGross pay:\t $%.2f\n”, basePay);
printf(“\nTaxes paid:\t $%.2f\n”, 0.20 * basePay);
printf(“\nBase pay:\t $%.2f\n”, basePay);
printf(“\nOvertime pay:\t $0.00\n”);
printf(“\nNet pay:\t $%.2f\n”, basePay -(basePay * 0.20));
}
}
}