Tax Calculation ID:6656


The yearly income of a person in rupees is passed as the input to the program. The program must print the tax to be paid with precision up to 2 decimal places based on the tax slabs given below.

Tax slabs:
Income up to 250000 = 0%
Income from 250001 to 500000 = 5% of income exceeding 250000
Income from 500001 to 1000000 = 20% of income exceeding 500000
Above 1000001 = 30% of income exceeding 1000000

Example Input/Output 1:
Input:
210000

Output:
0.00

Example Input/Output 2:
Input:
600000

Output:
32500.00

Explanation:
The yearly income of the person is 600000.
For the first 250000, the tax is 0%.
For the next 250000, the tax is 5%.
For the remaining 100000, the tax is 20%.
So the total tax to be paid is 0 + (5% of 250000) + (20% of 100000).
0 + 12500 + 20000 = 32500.

PROGRAM IN C:

#include <stdio.h>


int main()

{

int salary; 

float tax; 

scanf("%d",&salary);

int k=salary;

tax=0;

if(salary<=250000)

tax=0;

else if(salary>250000 && salary<=500000)

{tax+=(250000*0);

    tax=tax+((salary-250000)*0.05);

}

else if(salary>500000 && salary<=1000000)

{tax+=(250000*0)+(250000*0.05);

    tax=tax+((salary-500000)*0.20);

}

else if(salary>1000000)

{tax+=(250000*0)+(250000*0.05)+(500000*0.20);

tax=tax+((salary-1000000)*0.3);

}

printf("%.2f",tax);

return 0;

}


Comments

  1. there is no need for int k=salary;.Anyways we are use only salary in if condition

    ReplyDelete

Post a Comment

Popular Posts