Help! User defined functions

This is a discussion on Help! User defined functions within the C Programming forums, part of the General Programming Boards category; Ok, the problem is I need to calculate my net pay after taxes. I want to have a user defined ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    2

    Unhappy Help! User defined functions

    Ok, the problem is I need to calculate my net pay after taxes.

    I want to have a user defined function which calculates the math portion and displays the results in the main function. These are the parts of the problem:
    Medical plan deduction = $75.65

    Social security tax rate = 7.51%

    Federal income tax rate = 16.5%

    State income tax rate = 4.5%

    United Fund deduction = $15.00

    The medical deduction must be subtracted from the gross pay before the tax amounts are computed. Then the taxes should be computed and subtracted from the gross. As each one is computed, I want to print the amount. Finally, I need to subtract the United Fund contribution and return the remaining amount.
    ----------------------------------------------
    This is what I have thus far:
    Code:
    #include <stdio.h>
    
    float netpay()
    int main(void)
    {
       int grosspay;
       printf("This program calculates gross pay./n");
       printf("Please enter the gross pay: ");
       scanf("%d", &grosspay);
       return 0;
    
    }
    Please be gental I'm still very much a C newbie in need of help. I would appreciate any constructive help. Thanks.

    -Ricky

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    2

    What should I do now?

    Someone? Anyone?

  3. #3
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    First, don't post again asking for a response. When somebody sees your question who can help, they'll respond to it. Just be patient, they sit awhile sometimes. Second, you aren't posing a question. What do you need help with? If you just need help with how to write your program, post up your ideas first. If you have specific code examples, post those too. We want to help you. We don't want to just do your work for you.

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>float netpay()
    ... should probably be:
    >>float netpay(int grosspay)

    So, code the function like this:
    Code:
    float netpay(int grosspay)
    {
      float netpay;
      
      /* Do maths here */
      
      return (netpay);
    }
    And no more bumping threads please.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. user defined header files
    By sidu in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2008, 06:40 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Instant messenger app help
    By AusTex in forum C Programming
    Replies: 2
    Last Post: 05-01-2005, 12:41 AM
  4. Piecewise defined discontinuous functions in Mathematica
    By SourceCode in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 03-16-2005, 12:24 PM
  5. functions defined as a string
    By river-wind in forum C Programming
    Replies: 2
    Last Post: 11-21-2001, 09:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21