Thread: Help with if statement

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

    Help with if statement

    I need help with this program, I don't know what to do. I am not getting the amount of tax.
    /*This is program that displays the tax due over the amount of taxable income*/

    #include <stdio.h>

    int main()
    {
    float income=0, amount_of_tax=0;
    printf("Please enter the amount of taxable income: ");
    scanf("%d", &income);
    fflush(stdin);
    if (income < 750.00)
    amount_of_tax = .01 * income;
    else if (income < 2250.00)
    amount_of_tax = 7.50 + .02 * income;
    else if (income < 3750.00)
    amount_of_tax = 37.50 + .03 * income;
    else if (income < 5250.00)
    amount_of_tax = 82.50 + .04 * income;
    else if (income < 7000.00)
    amount_of_tax = 142.50 + .05 * income;
    else
    amount_of_tax = 230.00 + .06 * income;

    printf("The amount of tax due is: $%.2f\n", amount_of_tax);

    return 0;
    }

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    >scanf("%d", &income);
    income is a float, %d is for ints -- use %f.
    fflush(stdin) is not standard.
    Code tags make code easier to read.
    Last edited by Dave_Sinkula; 02-11-2003 at 10:01 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. Meaning of this statement?
    By @nthony in forum C Programming
    Replies: 7
    Last Post: 07-16-2006, 02:57 AM
  3. if/break statement
    By Apropos in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2005, 02:33 PM
  4. string & if statement
    By Curacao in forum C++ Programming
    Replies: 4
    Last Post: 05-02-2003, 09:56 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM