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);
}