-4

Not sure if this is enough to go by, but this section of my code is not working, it keeps underlining the "else if" part saying it is expecting an expression, or a statement, then asks for a (. I can provide full code if needed I just feel like I am missing something obvious here. I've tried everything. Thanks!

    if (total <= AMT1)
    {
        taxes = RATE1 * total;
        printf("your tax rate is: %f\n", taxes);
    }

    else if
    {
        (total > 300 || total <= 450);
        taxes = RATE2 * total;
        printf("your tax rate is: %f\n", taxes);
    }


    else if
    {
        (total > 450);
        taxes = RATE3 * total;
        printf("your tax rate is: %f\n", taxes);
    }

}

}

Spikatrix
  • 20,225
  • 7
  • 37
  • 83
user3247128
  • 359
  • 1
  • 3
  • 9
  • 2
    Treat yourself to [a good book on C](http://stackoverflow.com/q/562303/253056). – Paul R May 07 '16 at 07:45
  • 1
    You are indeed missing something fairly obvious. Might want to brush up on your C syntax a bit. – cf- May 07 '16 at 07:49
  • Remove the new line between `)` and `{` makes it neat, right? – Eric May 07 '16 at 07:50
  • @computerfreaker I have only been doing C for 8 weeks on and off. It's very late and I now see my mistake, placing the statement after the bracket instead of before, I'm sure you can understand that as a beginner, it isn't so "obvious" to me at first :) – user3247128 May 07 '16 at 07:56
  • 1
    @user3247128 I thought it might be something like that, hence the suggestion to brush up on syntax. I would have posted an answer but Rahn already had that covered. Don't worry too much about it, stuff like this happens to everyone. – cf- May 07 '16 at 07:58
  • 1
    Stop defacing your questions after you got your answer! – Jongware May 07 '16 at 09:12

1 Answers1

4
if (total <= AMT1)
{
    taxes = RATE1 * total;
    printf("your tax rate is: %f\n", taxes);
}

else if(total > 300 || total <= 450)
{
    taxes = RATE2 * total;
    printf("your tax rate is: %f\n", taxes);
}


else if(total > 450)
{
    taxes = RATE3 * total;
    printf("your tax rate is: %f\n", taxes);
}
Rahn
  • 4,787
  • 4
  • 31
  • 57