Hi,
I'm new in this forum and c language, need somebody to correct my programme as below:
Question
Design and implement an interactive program that reads your yearly gross salary and computes and prints your net monthly take home income. Assume that your yearly gross salary is greater than RM 50,000 but less than RM80,000, and the following deduction are applicable:
a) Federal income tax : RM 5100.00 plus 28% of gross income over RM 34,000.
b) State tax : 9% of gross income.
c) City tax : 1.75% of gross income.
d) Social security : 8.75% of the first RM 45,000 of gross income.
My programme/answer
#include <stdio.h>
main ()
{
int yearlygross;
int fedtax;
float statetax;
float citytax;
long socialsec;
float totaldeduction;
long netincome;
printf("Enter your yearly gross salary :");
scanf ("%d",&yearlygross);
fedtax = 5100+(0.28*yearlygross);
statetax = 0.09*yearlygross;
citytax = 0.0175*yearlygross;
socialsec = 0.0875*45000;
totaldeduction = fedtax+statetax+citytax+socialsec;
netincome = yearlygross-totaldeduction/12;
printf("Net monthly take home income is %dn", netincome);
return 0;
}
Let say the yearly gross is 60,000, the monthly net income should 2,309.30 after deduction all those taxes.
my calculation as below:
fed tax = 5100 + 16800 = 21900
statetax = 5400
citytax = 1050
social security = 3937.5
total = 32287.5 - 60000 = 27712.5 divide by 12 mths = 2309.30.
should I add "yearly gross>50000<80000"?
Not sure whether this is correct, but I can't get the correct answer
I guess I wrongly use integral data types.
Thank you in advance for your assistance.