# Tax Programme help

This is a discussion on Tax Programme help within the C Programming forums, part of the General Programming Boards category; Greetings I have been trying to write a programme to work out the tax paid on a person's income based ...

1. ## Tax Programme help

Greetings

I have been trying to write a programme to work out the tax paid on a person's income based on the different tax rates for different incomes. I keep getting an output value larger than the input value. Any help on this would be greatly appreciated.

Code:
```#include <stdio.h>

// Prints out the tax that is paid from a given income
int main(){
int income = 13000; // person's income before tax
float tax_rate_1 = 0.105;
float tax_rate_2 = 0.175;
float tax_rate_3 = 0.30;
float tax_rate_4 = 0.33;
int income_left;
int income_left2;
int total_tax1 = 0, total_tax2 = 0, total_tax3 = 0, total_tax4 = 0;
int income_tax;

if (income <= 14000) // for income less than \$14000
total_tax1 = income * tax_rate_1;

if (income <= 48000 && income > 14000)
income_left = income - 14000;
total_tax2 = income_left * tax_rate_2;

if (income <= 70000 && income > 48000)
income_left2 = income - 48000;
total_tax3 = income_left2 * tax_rate_3;

if (income > 70000);
total_tax4 = (income - 70000) * tax_rate_4;

income_tax = total_tax1 + total_tax2 + total_tax3 + total_tax4;
printf("Total tax paid is \$%d\n", income_tax);

}```

2. Here lies the main problem at hand:

Code:
```if (income > 70000);
total_tax4 = (income - 70000) * tax_rate_4;```
The "if()" statement is followed by an null statement (just ';' and perfectly legal in 'C'), so the next line is always getting executed. With your seed value of "income," this will yield a negative result.

~

I would also like to add caution! You're using floats for your tax rates, but storing them, adding them, and printing them as integers!! Change those variables to type float and the format specifier in your "printf()" to "%f".

3. You forgot brackets for your compound if statements and your last if statement contains a ';' which shouldn't be there.
e.g.
Code:
```if(something){
....do something
}```
Additionally, you declare main as returning an int, however you do not in this program. Bare bones C program is:
Code:
```int main(void){

return(0);
}```

4. Ah, a semicolon where there should not be one!. I have fixed up the errors and it works now. Thanks for the assistance.