Re: Help I'm stuck on code.
Re: Help I'm stuck on code.
Patience :P
Those who can answer your question are not on 24/7
A simple way to implement this logically is by comparing the income with the maximum values of each range using if-else statements (can you see why?)
Also, it's important to figure out if $10000 belongs to the lower bracket or the higher bracket (also with the other brackets). This will determine if you need a < or a <= operator.
Code :
double taxRate = 0;
if (pay< 10000)
{
taxRate = 0;
}
else if (pay < 25000)
{
taxRate = 0.1;
}
else if (pay < 50000)
{
taxRate = .2;
}
else
{
// pay > 50000
taxRate = .3;
}
Re: Help I'm stuck on code.
Quote:
Originally Posted by
helloworld922
Patience :P
Those who can answer your question are not on 24/7
A simple way to implement this logically is by comparing the income with the maximum values of each range using if-else statements (can you see why?)
Also, it's important to figure out if $10000 belongs to the lower bracket or the higher bracket (also with the other brackets). This will determine if you need a < or a <= operator.
Code :
double taxRate = 0;
if (pay< 10000)
{
taxRate = 0;
}
else if (pay < 25000)
{
taxRate = 0.1;
}
else if (pay < 50000)
{
taxRate = .2;
}
else
{
// pay > 50000
taxRate = .3;
}
thanks for your help