RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 499 | Replies: 4
Reply
Join Date: Nov 2007
Posts: 3
Reputation: SofMy is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SofMy SofMy is offline Offline
Newbie Poster

Anybody to correct my programme

  #1  
Mar 2nd, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 55
Reputation: carnage is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
carnage carnage is offline Offline
Junior Poster in Training

Re: Anybody to correct my programme

  #2  
Mar 2nd, 2008
netincome = yearlygross-totaldeduction/12;

that should be

netincome=(yearlygross-totaldeduction)/12;
Reply With Quote  
Join Date: Jan 2008
Posts: 55
Reputation: carnage is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
carnage carnage is offline Offline
Junior Poster in Training

Re: Anybody to correct my programme

  #3  
Mar 2nd, 2008
one more thing

if you were asked to validate the input yearly gross
have something like this:

  1. do{
  2. printf("Enter your yearly gross salary :");
  3. scanf ("%d",&yearlygross);
  4. }while (yearlygross<50000||yearlygross>80000);


//edit: sorry for the double post.
Last edited by carnage : Mar 2nd, 2008 at 7:56 am.
Reply With Quote  
Join Date: May 2006
Posts: 2,803
Reputation: WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold 
Rep Power: 16
Solved Threads: 237
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Maven

Re: Anybody to correct my programme

  #4  
Mar 2nd, 2008
Originally Posted by carnage View Post
//edit: sorry for the double post.

If you don't want want to double post, you can edit your first post. But double posting is not a problem if you have additional information. It's bumping we frown on.
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
Reply With Quote  
Join Date: Nov 2007
Posts: 902
Reputation: mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough mitrmkar is a jewel in the rough 
Rep Power: 6
Solved Threads: 188
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: Anybody to correct my programme

  #5  
Mar 2nd, 2008
>> you can edit your first post.
It seems that once posted, a post remains editable for some short period of time and then enters a non-editable mode. Is there any way, for one to edit one's own post regardless of how long it has been on the forum?

By the way, what is 'bumping' in this context?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:17 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC