function is not behaving!

I have parced and hacked this function every which way, but can't figure out why it gives the wrong result for the middle statement. If you see something I don't please advise. If you need to see the entire code I'll post it.

1
2
3
4
5
6
7
8
9
10
11
  
double calcTax(double)
{
        if (net <= 15000)
        netnet = net * 0.15;// THIS IS ACCURATE
        else if (net>=15001&&net<=40,000)
        netnet = 0.25*(net-15000)+2250;// ... BUT THIS ISN'T!!!
        else if (net>=40,001)
        netnet = 0.35*(net-40000)+8460; // YET THIS IS!!!           
        return netnet;
}
You didn't give the parameter a name, and the netnet and net are undefined.
I think that you have a typo in the second if statement.
40000 should not have comma 40,000.

This way you are passing 2 parameters into the if statement- like if(a, b)
And the third one as well.
they're defined elsewhere. I will remove the commas (dumb) and see if it works. I'll bet it does.
(20 seconds later) THANK YOU. vlkon. Good eye! I guess sometimes we can stare at something and yet not see it. Lesson learned. Thanks again!!!
Last edited on
they're defined elsewhere
I would advise against using global variables.
Topic archived. No new replies allowed.