CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Junior Member
Join Date
Mar 2008
Posts
9

## Program Problem

I am writing a program that is supposed to calculate the federal tax. The tax calculated as follows: For single people, the standard exemption is \$4000; for married people, the standard exemption is \$7000. A person can also put up to 6% of his or her gross standard income in a pension plan. The tax rates are as follows: If the the taxable income is

1) Between \$0 and \$15000, the tax rate is 15%
2) Between \$15001 and \$40000, the tax is \$2250 plus 25% of the taxable income over \$1500
3) Over \$40,000, the tax is \$8460 plus 35% of the taxable income over \$40000
Prompt the user to enter the following information:
4) Martial status
5) If the marital status is "married", ask for the number of children under the age of 14
6) Gross salary(if the martial status is "married" and both spouses have income, enter the combined salary.)
7) Percentage of gross income contributed to a pension fund.

The program must consist of at least the following functions:
a) function getData: this function asks the user to enter the relevant data.
b) function taxAmount: this function computes and returns the tax owned.

To calculate the taxable income, subtract the sum of the standard exemption, the amount contributed to a pension plan, and the personal exemption, which is \$1500 per person.

This is the my code so far. I don't know what is wrong with me but I am either dumb (possible) or have a severe brain blockage (also possible). Am I going about this the completely wrong way? Or am I just missing something thats hiding in plain sight?

Code:
#include<iostream>
#include<cctype>
#include<string>

using namespace std;

void getData();
double taxAmount(int, double, double, int);
int getNumKids();

int main()
{
void getData();

return 0;
}
void getData()
{
int state;
int numKids;
double salary;
int numPerson;

cout<<"Please enter: 0 for Single or 1 for Married "<<endl;
cin>>state;

if(state == 1)
{
numKids = getNumKids();

cout<<"Please enter Y or N if both of you earn income or not: "<<endl;

{
cin>>salary;
}
else
{
cin>>salary;
}
numPerson = 2 + numKids;
}
else
{
cin>>salary;
numPerson = 1;
}

double taxAmount(numPerson,salary, amountInPension, standardExemption)
{
taxableIncome = salary - (1500.00 * numPerson) - amountInPension - standardExemption;
return(taxableIncome);
}
}
int getNumKids()
{
int kids;

cout<<"Please enter number of kids under the age of 14: ";endl;
cin>>kids;
return kids;
}

2. Junior Member
Join Date
Nov 2007
Posts
24

## Re: Program Problem

Hi

What is the behavior you see as opposed to the behavior you expect?

I looked at the code briefly and here are my observations:

1-do you call the taxAmount() function somewhere in the code?

2-in the taxamount() function, you don't specify the type of taxableIncome. In this case, taxableIncome is pretty useless since you can return expressions like in the following: return (iSomeInt+iSomeOtherInt+2) but if you REALLY want to use it, at least specify its type.

Good luck!

racette
Student in software engineering

3. Junior Member
Join Date
Nov 2007
Posts
24

## Re: Program Problem

I also just noticed that in the main() function, you call the getData() function but you put the word 'void' right in front of it.

You should put 'void' only in the function prototype, not when calling it.

To call it, just write:

getData();

without 'void' in front of it.

Good luck!

racette
Student in software engineering

4. Junior Member
Join Date
Mar 2008
Posts
7

## Re: Program Problem

a) check curly braces.
b) call the functions

5. Elite Member
Join Date
Oct 2006
Location
Sweden
Posts
3,654

## Re: Program Problem

Also go back and edit your post and use code tags. Read how to do it here http://www.codeguru.com/forum/misc.php?do=bbcode

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•