No. Whatever your teacher said, its right. I would suggest you to go ahead with your original post..
When you are having it in sequence, like this.
if (annual_salary >= 0 && annual_salary <= 16500)
{
tax_rate = 11.32F;
pay_rate = 8.68F;
}
else if (annual_salary <= 19500)
{
tax_rate = 15.14F;
pay_rate = 10.26F;
}
its same as
if (annual_salary >= 0 && annual_salary <= 16500)
{
tax_rate = 11.32F;
pay_rate = 8.68F;
}
else if (annual_salary >= 16500 && annual_salary <= 19500 )
{
tax_rate = 15.14F;
pay_rate = 10.26F;
}
For eg, when i pass 17000, definitely it will take tax rate as 15.14F, since it will fail first if loop and enters else if.
If you want to test the complete code,
use the following values and run once and test your code.
Input:Annual_salary Expected:Tax_rate
14000 11.32F
17000 15.14F
21000 22.65F
32000 27.1F
34000 30.92F
45000 35.72F
78000 40.72F
91000 50.52F