Please support our C++ advertiser: Programming Forums
Views: 499 | Replies: 4
![]() |
•
•
Join Date: Nov 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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 %d\n", 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.
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 %d\n", 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.
•
•
Join Date: Jan 2008
Posts: 55
Reputation:
Rep Power: 1
Solved Threads: 2
one more thing
if you were asked to validate the input yearly gross
have something like this:
//edit: sorry for the double post.
if you were asked to validate the input yearly gross
have something like this:
c++ Syntax (Toggle Plain Text)
do{ printf("Enter your yearly gross salary :"); scanf ("%d",&yearlygross); }while (yearlygross<50000||yearlygross>80000);
//edit: sorry for the double post.
Last edited by carnage : Mar 2nd, 2008 at 7:56 am.
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
-- Pearl Williams
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode