GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jul-2007, 06:52
Bradster Bradster is offline
New Member
 
Join Date: Jun 2007
Posts: 7
Bradster is on a distinguished road

C++ to figure Taxes


I've got a coding project to take user input on income and calculate income tax based on that. For Example Married filing Jointly income of $70,000 yields a total tax of $10,615

It's broken down like
first 15,100 is charged 10% tax so 15,100 * .01 = $1510

15,101 to 61,300 is charged 15% tax so 46200 *.15 = $6930

61,301 to 70,000 is charged 25% tax so 8700 *.25 - $2175

I'm sort of stumped on how to figure the taxes based on the range... If it was a flat tax rate say 25% if you make 70,000 i'd be a no brainer, but in this case each chunk of the income may fall into a different rate up to the total of 70000 as in the example. Anyone have some tips on how to handle that?
  #2  
Old 11-Jul-2007, 07:51
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,648
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: C++ to figure Taxes


Quote:
Originally Posted by Bradster
I've got a coding project ... Anyone have some tips on how to handle that?

Pretend you are taking a test (no computers allowed, but non-programmable calculators that add, subtract, multiply and divide are allowed). Calculate taxes for the following:

1. Total income is 12,345.67

2. Total income is 34,567.90

3. Total income is 67,890.12

Show your work.


Regards,

Dave
  #3  
Old 11-Jul-2007, 08:14
Bradster Bradster is offline
New Member
 
Join Date: Jun 2007
Posts: 7
Bradster is on a distinguished road

Re: C++ to figure Taxes


I was trying to think... take the user input for income say income_Varible


Then something like if income_Variable < top range of income level 1 then

incometax = income_Variable * tax_rate for level 1

If income_Variable > income level 1 then take the difference (income_Variable - top amount income level 1) * tax_rate for level 1

But I'm not sure if I am over complicating the issue.... I'm a beginner C++
  #4  
Old 11-Jul-2007, 12:25
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,648
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: C++ to figure Taxes


Quote:
Originally Posted by Bradster
I'm a beginner C++

That's why I suggested that you work it out with pencil and paper. Don't worry about C++ or variables or any blooming thing else. Do the calculations.


Now, the steps in a computer program may not be exactly the same as with pencil and paper, but if you can't go to the trouble to go through some examples, I can't see any way on this beautiful green earth that you could expect to write a program to do it. (Also, how would you test the program to see if it is correct if you don't have some examples for which you know the answer?)

Here is how I might do it with pencil and paper:

Code:
Case 1: Income = 12,345.67 Step1: Is income greater than 15,100? Answer: No. Then amount at rate number 1 = income Then tax at rate number 1 = (amount at rate number 1) * (rate number 1) Result: tax at rate number 1 = 12,345.67 * 10% tax at rate number 1 = 1,234.57 Since the amount was less than 15,100, we are done: total tax = tax at rate number 1 total tax = 1234.57 ------------------------------------ Case 2: Income = 34567.90 Step 1: Is amount greater than 15,100? Answer: Yes. Then tax at rate number 1 = 15,100 * rate number 1 Result: tax at rate number 1 = 15,100 * 10% Since the income is greater than 15,100, we have to calculate the amount at rate number 2 Step 2: Is income greater than 61,300? Answer: No. Then after calculating the amount at rate number 2, we will be through. Then tax at rate number 2 = (amount at rate number 2) * (rate number 2) tax at rate number 2 = (income - 15,100) * (rate number 2) tax at rate number 2 = (34567.90 - 15,100) * (rate number 2) tax at rate number 2 = 2920.19 total tax = tax at rate number 1 + tax at rate number 2 total tax = 1510.00 + 2920.19 total tax = 4430.19 etc.

Regards,

Dave
 
 

Recent GIDBlogFlickr uploads of IA pictures by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bodybuilding and figure Marilia05 Sports Forum 3 30-Oct-2006 21:30
can't figure this out (classes cross referencing) ehudros C++ Forum 4 12-May-2006 09:29
Need Help Modifying Code sosy2001 C Programming Language 10 17-Nov-2004 07:07
NOT sure what is wrong with script fscanf jenmaz C Programming Language 14 29-Oct-2004 14:53
Can't figure out errors crystalattice C++ Forum 3 17-Jul-2004 07:58

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:44.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.