# yet another dilemma...when they will end? :)

• 09-16-2004
Chaplin27
yet another dilemma...when they will end? :)
Hello everyone!
Let's cut the crap and jump right into this one...shall we? ;) haha, anyways, ok...here's the question: the problem I'm faced with right now is I'm trying to write a program that will take a users dollar input (let's use the example 38000) and then make a loop that will have the following parameters of taxation -
the first 5000 = 0% tax
next 10000 = 10% tax
next 20000 = 15%
anything after 35000 = 20%

so....if the user enters 38000...they would owe 5000 x 0.00 + 10000 x .010 + 20000 x 0.15 + 3000 ( this is 3000 b/c 38000 - 35000, just in case I'm being too vague) x 0.20...which should come out to 4600...ok, so I tried some if else statements and they started getting demanding hehe...I can't seem to figure out how to make a trickle down system where basically if the user enters 38000 it would break that down into 30000, 20000, 10000, 5000....something like that...ARG, too early haha...any help would be great, if I'm being too vague tell me...Thanks -Chap
• 09-16-2004
hk_mp5kpdw
Code:

```double tax( double income ) {     double temp;         if( income < 5000.0 ) return 0.0;     income -= 5000.0;     if( income < 10000.0 ) return income * .10;     else     {         temp =  10000.0 * .10;         income -= 10000.0;     }     if( income < 20000.0 ) return temp + income * .15;     else     {         temp += 20000.0 * .15;         income -= 20000.0;     }     temp += income * .20;     return temp; }```
• 09-16-2004
curlious
I would suggest you post code that you have attempted and that people do not blindly post a solution how is a person supposed to learn if they are given the answer.