Thread: Need some help

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    118

    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. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    118
    Quote Originally Posted by tabstop View Post
    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. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, then you should look into math.h, especially this function.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    118
    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.

Popular pages Recent additions subscribe to a feed