Some comments to your code. First take a look at this while-loop:
Code:
do
{
printf("Enter number of hours worked:\n " );
scanf( "%d", &hours );
if (hours >40)
printf("The number of regular hours should not exceed 40\n");
else if (hours < 0)
printf("The number of regular hours should be greater than 0\n");
}
while(hours > 40 || hours < 0);
I made the second if a else-if. If hours > 40, then hours < 0 is FALSE. So when hours > 40, it would be a waste of time to check if hours < 0.
Further I removed the unnecessary brackets. The same for the next while-loop.
Code:
do
{
printf("Enter number of overtime hours worked:\n");
scanf( "%d", &overtime);
if (overtime >72)
printf("The number of overtime hours should not exceed 72\n");
}
while (overtime>72);
This
is a little inefficient. The variable parkfree is used as a constant, why not make a define? It saves a variable and assignment-time. By the way, I see a lot of constant numbers in the calculations. It would be better to make defines with logical names to define those constants.
1. It makes the code more readable.
2. It makes the code better maintanable.
When changes need to be make, you just take a look at your constants and change them. Then in the whole program they are changed and you don't need to worry about forgetting to change one of them somewhere around in the code.