# Basic C Programming help??

#### Khalid Abur-Rahman

Joined Dec 25, 2008
35
Can anyone in any possible way please help me with this basic C code. I will admit that this is homework, but it is late. I got caught up and stuck with trying to learn arrays, now I am stuck. I just need to get this assignment done, I will just read to catch up and do the future assignments myself. I am taking a six week summer course in C.
Write a method that prompts the user for hours worked, rate and name. Use parameter passing, and pass by reference.

here is the assignemt and the code as I have written it so far. Please make the following changes:

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++) {

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));

}

}

}

#### retched

Joined Dec 5, 2009
5,208
Do us a favor and edit your post, putting the code in 'code' tags.

It will make cutting and pasting easier and increase readability.