# Need some help

This is a discussion on Need some help within the C Programming forums, part of the General Programming Boards category; I need determine LTB (Long Term Benefits) which is determined by each full \$100 of the gross pay being worth ...

1. ## Need some help

I need determine LTB (Long Term Benefits) which is determined by each full \$100 of the gross pay being worth \$2

So an example would be 589 would be 500, thats 5 100's, so the total LTB would be \$10 (5 * 2 = \$10)

you can see what i used pre-post
Code:
ltb = (gross / 100) * 2;
but that doesnt work as it rounds

ie 517 would be 5 but 589 would be 6 (it should be 5 in this case)

edit: i dont need it to be done, some tips would be appreciated

2. Are you sure?
Code:
#include <stdio.h>
#include <stdlib.h>

int main() {

int gross = 589;
int ltb;

ltb = (gross / 100) * 2;
printf("The computed long term benefits are \$%d.\n", ltb);
return 0;
}
gives
Code:
The computed long term benefits are \$10.

3. Originally Posted by tabstop
Are you sure?
Code:
#include <stdio.h>
#include <stdlib.h>

int main() {

int gross = 589;
int ltb;

ltb = (gross / 100) * 2;
printf("The computed long term benefits are \$%d.\n", ltb);
return 0;
}
gives
Code:
The computed long term benefits are \$10.
ya, it may be because my gross variable is a double though perhaps??

4. Well, then you should look into math.h, especially this function.

5. yes thanks that works but i have one last problem i have to calculate federal tax and i've been trying to figure out a formula for awhile now.

Code:
Federal tax (FT) is deducted from gross pay. FT is calculated
based on what a person would earn for a full year, assuming that
the employee will make the current week's gross pay every week
for a full 52 weeks. The rates are:
o 16&#37; on the first \$20,000 earned annually
o 23% on the next \$20,000 earned annually
o 29% on the remainder earned annually

Provincial Tax (PT) is collected by the Federal Government in
all provinces (except Quebec, which we will ignore for the
purposes of this assignment). PT is calculated at 47% of the
Federal tax, and is simply added to FT.

An example of a gross weekly pay of \$598.50 would be calculated
as an annual pay of \$31,122 (598.50 * 52), which will result in
a total FT (including PT) of \$162.78
((20,000 * 0.16 + 11,122 * 0.23) / 52 * 1.47).
if anyone can give me some pointers (no a programming pointer) on how i could do this?

the way tried is way to hard to explain though i have a bit of the code left

Code:
double cFT(double gross) {
double annual = 0, ft16, ft23 = 0, ftremain = 0, ft;
annual = gross * 52;
ft16 = annual - 20000;
if (ft16 > 20000) {
ft23 = ft16 - 20000;
ft16 = 20000;
ft23 = ft16 - 20000
ftremain = ft23
ft = (
it was giving me off numbers like some where negatives so just seeing if someone can help with a new formula to figure this out.