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 24-May-2004, 11:06
homz homz is offline
New Member
 
Join Date: May 2004
Location: ohio
Posts: 23
homz is on a distinguished road

Help in solving this C++ problem.....


write a program tht can be used to calculate the federal tax. The tax calculated as follows: For single peopl, 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 $1500 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 leat 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.

i have this so far
CPP / C++ / C Code:
#include <iostream>

using namespace std;

enum status{single, married};
void getStatusData();
double taxAmount(state, numPerson, salary);
int getNumKids();

int main()
{   
     void getStatusData();

     return 0;
}
void getStatusData()
{
	status state;
	int noOfKids;
	char answer;
	double salary;
	int numPerson;

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

	if (state = ("married" || "Married"))
	{
		noOfKids = getNumKids();
	
		cout<<"Please enter Y or N if both of you earn income or not: "
		<<endl;
	    cin>>answer;

	    if (answer=('Y'||'y'))
	    {
		cout<<"Please enter your combined salary: "<<endl;
		cin>>salary;
	    }  
		else 
	    {
		cout<<"please enter your salary: "<<endl;
		cin>>salary;
	    }
		numPerson = 2 + noOfkids;
	}
	else 
	{
		cout<<"please enter your salary: "<<endl;
		cin>>salary;
		numPerson = 1;
	}

	double taxAmount(status state, int numPerson, double salary)
	{
      	taxableIncome= ((15% of salary - 7000)- (1500 * numPerson))
	}
}
int getNumKids()
{
	int kids;

	cout<<"Pleae enter number of kids under the age of 14: ";endl;
	cin>>kids;
	return kids;
}
  #2  
Old 24-May-2004, 12:05
dabigmooish's Avatar
dabigmooish dabigmooish is offline
Member
 
Join Date: May 2004
Location: Baltimore (middle of Canton)
Posts: 167
dabigmooish will become famous soon enough
you seem to be on the right track. I have only a few suggestions:
1) instead of having or statements in all of your if statements you could use the toupper(string) function. What this does is convert whatever string you input to all uppercase letters. The return value is the uppercase string. (I myself just learned this one thanks to WaltP).

2)In the getStatusData() function you need to ask the person if they would like to put any of thier money into a pension. Next you need to check that the pension is equal to or less then .06 * gross standard income.

3)You should also have a variable called standardExemption that will equal 7000 when they say they are married or 4000 when they say they are single.

4)
CPP / C++ / C Code:
double taxAmount(status state, int numPerson, double salary)
  {
        taxableIncome= ((15% of salary - 7000)- (1500 * numPerson))
  }
could now look like:

CPP / C++ / C Code:
double taxAmount(int numPerson, double salary, double amountInPension, int standardExemption)
{
     taxableIncome = salary - (1500.00 * numPerson) - amountInPension - standardExemption;
     return(taxableIncome);
}

5) To determine the tax rate simply use a switch statment.


Hope this helps you out
  #3  
Old 24-May-2004, 18:55
homz homz is offline
New Member
 
Join Date: May 2004
Location: ohio
Posts: 23
homz is on a distinguished road

giving error message????


I cant figure out the error message its giving me on cin(state) it says no in message what does it mean????? and how can i fix it????
CPP / C++ / C Code:
#include <iostream>

using namespace std;

enum status{single, married};
void getStatusData();
double taxAmount(int, double, double, int);
int getNumKids();

int main()
{   
	void getStatusData();

    return 0;
}
void getStatusData()
{
	status state;
	int noOfKids;
	char answer;
	double salary;
	int numPerson;
    double standardExemption;
    double tax;

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

	switch (state)
     {
        case: "married" case:"Married";

		noOfKids = getNumKids();
	
		cout<<"Please enter Y or N if both of you earn income or not: "<<endl;
	    cin>>answer;

	    if (answer=('Y'||'y'))
	    {
		cout<<"Please enter your combined salary: "<<endl;
		cin>>salary;
	    }  
		else 
	    {
		cout<<"please enter your salary: "<<endl;
		cin>>salary;
	    }
		numPerson = 2 + noOfkids;
                break;

        case: "single" case:"Single";
	
		cout<<"please enter your salary: "<<endl;
		cin>>salary;
		numPerson = 1;
	
		cout<<"please enter your contribution to pension: "<<endl;
		cin>>standardExemption;

      tax= taxAmount(state, numPerson, salary, standardExemption);
	 }
int getNumKids()
{
	int kids;

	cout<<"Pleae enter number of kids under the age of 14: ";endl;
	cin>>kids;
	return kids;
}
//double taxAmount(int numPerson, double salary, double amountInPension, int standardExemption)
double taxAmount(status state, int numPerson, double salary, double pensionrate)
{ 
    double taxableincome;
    double tax;
    /*double standardExemption;
    
     taxableIncome = salary - (1500.00 * numPerson) - amountInPension - standardExemption;
     return(taxableIncome);*/
}

switch (state)
{
case single:
taxableincome = salary-4000-1500*numPerson-(standardExemption*salary)/100;
break;
case married:
taxableincome = salary-7000-1500*numPerson-(standardExemption*salary)/100;
break;

}

switch (taxableincome)
{
case>0 & case is<15000
tax = .15*taxableincome;
break;
case>15001 & case is<40000
tax = 2250 + .25*(taxableincome-15000);
break;
case>0 & case is<15000
tax = 8460 + .35*(taxableincome-40000);
}

return tax;
  #4  
Old 24-May-2004, 22:04
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by homz
I cant figure out the error message its giving me on cin(state) it says no in message what does it mean????? and how can i fix it????
By doing it right?

Problem 1:
CPP / C++ / C Code:
enum status{single, married};
...
status state;
...
cout<<"Please enter: Single or Married "<<endl;
cin>>state;
State cannot be entered because it's an enum. Also, it's value is only 0 or 1 (for single or married enum) It's not a string.

Problem 2:
CPP / C++ / C Code:
switch (state)
{
    case: "married" case:"Married";
1) you cannot use a string as a case value.
2) you need a : after the case value, not after the case keyword.

Problem 3:
CPP / C++ / C Code:
if (answer=('Y'||'y'))
look up the syntax for the if statement. What you have is:
a) 'Y'||'y' giving the value TRUE or FALSE -- TRUE or 1 in this case
b) assign that 1 to answer
c) if (TRUE) -- which the value of answer is, do the IF block


I would suggest reading up on standard C/C++ syntax and forget the use of enum until you understand the basics. At this point you don't understand if, switch, case syntax yet.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
 
 

Recent GIDBlogNot selected for officer school 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
C I/O problem kelly80 C Programming Language 4 27-Apr-2004 20:15
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53
problem with php5 cgi installation fab13 Apache Web Server Forum 3 19-Nov-2003 09:11
unwanted scrollbar problem kelly001 Web Design Forum 3 24-Oct-2003 10:44
join problem zuzupus MySQL / PHP Forum 0 14-Aug-2003 05:11

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

All times are GMT -6. The time now is 14:10.


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