A while ago i had requested help for a Marital and Federal tax program. Unfortunately I'm making this program for a particularly picky person. So I ended up having to remake it somewhat. If someone could take a look and help me with this that'd be cool. Here's what I got:

FederalTaxHeader.h

#ifndef header_h
#define header_h


#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <cctype>
#include <cstdlib>
#include <fstream>


using namespace std;

namespace Federal_Taxes
{
enum GrossType {LowGross, MedGross, HighGross};
}
using namespace Federal_Taxes;
	//List of the different functions
	
void extern displayRedo ();
char extern MaritalStatus(int Single, int Married);
void extern displayStatus (MaritalType GrossType);
void extern displaygross (int gross);
void extern displayInsuranceCheck ();

char extern getMaritalStatus (char & married);
{);
int extern getGross ();

char extern response ();

void extern askMaritalStatus ();
void extern displayUsage ();
void extern displayPurpose ();
char extern getAnswer ();

void extern myLabel ( const char * assignment, const char * date,
               ostream & out);
#endif

calc.cpp

#include "FederalTaxheader.h"

 //recieve sides from main, while useing the enum type declared in main
{

    GrossType gross; //declares shape under the enum type
    
    if (gross < 0)
     void displayRedo ()
{
	cout << "\n You have inputted an invalid entry" 
    "would you like to use this program again? Y/N ";

}
           	if (gross < 15001)
            gross = LowGross;
				
                else if (gross < 40001)
				gross = MedGross;
                
                else if (gross > 40000)
                gross = HighGross;
                }
   
	return GrossType;
}

getData.cpp

#include "FederalTaxheader.h"


using namespace std;
int getNumChildren();
double taxAmount(int,double,double,int);


int main ()
{
    void getData();
    

    getData();  



    return 0;
}
void getData()
{
    
    char status;
    char answer;
    int noofChildren;
    double salary;
    double amtInPension;
    int numPerson;
    int standardExemption;
    double tax;

    cout << "Enter your Marital Status: M for Married or S for Single ";
    cin >> status;
    cout << endl;

    if  (status == 'm' || 'M')
    {    
            noofChildren = getNumChildren();

            cout << "Do both spouses earn income? Please enter Y or N. ";
            cin >> answer;
            cout << endl;

              if (answer == 'y' || 'Y')
                {    
                    cout << "Please enter combined salary: ";
                    cin >> salary;
                    cout << endl;
                }
        
              else if (answer == 'n' || 'N')
              {
                  cout << "Please enter salary: ";
                  cin>> salary;
                  cout<< endl;
              }

              numPerson = 2 + noofChildren;
    }
    else
    {
        cout << "Please enter salary: ";
        cin >> salary;
        cout << endl;

        numPerson = 1;
    }

    cout << "Please enter contribution to the Pension Plan: ";
    cin >> amtInPension;
    cout << endl;

    tax = taxAmount(numPerson, salary, amtInPension, standardExemption);
}

int getNumChildren()
{
    int children;

    cout << "Please enter number of Children under Age 14: ";
    cin >> children;
    cout << endl;
    
    return children;
}

double taxAmount(int numPerson, double salary, double amtInPension, int standardExemption)
{
    double taxableIncome;


taxableIncome = salary - (1500.00 * numPerson) - amtInPension - standardExemption;
     return(taxableIncome);
}

input.cpp

#include "FederalTaxheader.h"

char getAnswer () // answer to question so it can continue 
{
	char answer;
		
		do
		{
		cin >> answer;
		answer = toupper (answer);
		cout << " ";
		void Flush ();
		}
		while (answer != 'Y' && answer != 'N');

	return (answer);
}

int getMaritalStatus (char & married)
{   
    char maritalType
    int kidnum = 0
    do
    {
    cout << "Enter 'M' for married 'S' for single." << endl;
    
     cin >> MaritalType;
    MaritalType = toupper (MaritalType);
    while (MaritalType != 'M' || MaritalType != 'S')
    married = MaritalType;
    
if ( married == 'M' )

{

cout << "How many kids under the age of 14 do you have?" 
 "Enter a whole number only!" << endl;

cin >> kidNum;
}

return (kidNum);
}


int getgross ()

{
	int gross;
      	do
          {     
		askgross ();
		cin >> gross;
		void Flush ();
}       while ( gross <= 0 );
		return gross;
}

main.cpp

#include "FederalTaxheader.h"

int main ()
{
    char MaritalType;
	char response;
	char Answer2; 

				displayPurpose (); //shows what the program does
          
                response (); 

			{do
			{
				
				GrossType gross; 
                
				int Low_RATE; 
				int Med_RATE;
				int High_Rate;
			do
			{
				gross = 0; // gross is set to = 0 just in case...

				
				gross = getgross ();
				

			}
			while (response == 'Y');

if married
   cout << "gross is income of both spouses."
   else
  cout << "gross is your income."
				
                gross = MaritalStatus (MaritalStatus, gross); 
				displayStatus (GrossType);

				displayRedo ();
				Answer2 = getAnswer ();
			}
			while (Answer2 == 'Y');
}
    myLabel ("Federal Taxes 2.0", "02/23/2008", cout);
    system("PAUSE");
    return EXIT_SUCCESS;
}

output.cpp

#include "FederalTaxheader.h"

void displayPurpose ()
{
	cout << "\nThis program Calculates your Federal Taxes. It calculates" << endl;
	cout << "how much you pay if you are single or married." << endl;
	cout << "\nIt also allows the user to set up a pension plan if he/she" << endl;
	cout << "wishes" << endl;
	cout << "Between $0 and $15,000 the tax rate is 15%" << endl;
	cout << "Between $15,001 and $40,000 the tax is $2,250 plus 25% taxable" << endl;
	cout << "income over $15,000" << endl;
	cout << "Over $40,000, the tax is $8,460 plus 35% of the taxable income" << endl;
	cout << "over $40,000." << endl;
	cout << "When you enter your gross you will be prompted to enter the amount"
	cout << "of kids that you have" << endl;
	cout << "This will affect how much you have to pay." << endl;
    cout << "\nTo get this program started, you must enter you marital status." << endl;
}

char response ()
{
char response;     
cout << "Do you want to use this program?";
cin >> response;

return (response);
}
void askgross ()
{
	cout << "Enter Your gross income " << endl;

}

void askMaritalStatus ()
{
	cout << "Please say whether you are single or married" << endl;

}


void displayInfo (int gross, int position)
{
	cout << "\n-this is the information that you inputted-" << endl;
	cout << "\nGross income: " << gross << endl;
	cout << "Marital Status: " << position << endl;
}

void displayStatus (char MaritalType, GrossType TypeOfGross) // prints the determined shape.
	{	
    switch (GrossType) 
		{
		case LowGross:
        cout << "\nSince you make between $0 and $15000 your tax rate is 15%." << endl;
        break;
        case MedGross:
        cout << "\nSince you make between $15001 and $40000 you must pay $2250" << endl;
        cout << "in tax money plus 25% of the taxable income over $15000." << endl;
		break;
		case HighGross:
        cout << "\nSince you make over $40000 you must pay $8460" << endl;
        cout << "in tax money plus 35% of the taxable income over $40000." << endl;
		break;
    }
}
void displayRedo ()
{
	cout << "\nWould you like to use this program again? Y/N ";

}

tacamount.cpp

#include "FederalTaxheader.h"

double taxAmount(int numPerson, double salary, double amtdeducted, int standardExemption)
{
    double taxableIncome, marginalIncome, marginTax;
    int tax;
    int baseTax, totalTax;


taxableIncome = salary - (1500.00 * numPerson) - amtdeducted - standardExemption;
     
	if (tax >= 0 || tax <= 15000)
	{
		marginTax =.15 * taxableIncome;
		totalTax = marginTax;
	}
	else if (tax >= 15001 || tax <= 40000)
	{
		marginalIncome = taxableIncome - 15000;
		marginTax = .25 * taxableIncome;
		baseTax = 2250;
		totalTax = baseTax + marginTax;
	}
	else if (tax > 40000)
	{
		marginalIncome = taxableIncome - 40000;
		marginTax = .35 * taxableIncome;
		baseTax = 8460;
		totalTax = baseTax + marginTax;
	}

		return(totalTax);
}

Many thanks to whoever checks this out. If incase you can't remember what it is that I'm trying to accomplish, it says it in the output file. Thanks again

Recommended Answers

All 10 Replies

Does it not work or have you not fulfullied the persons needs?? and also i think it would be better if you give the problem again because some people would not have the time to look at your previous thread

The problem is that I am unsure as to what else I need to add to the program in order to make it comile. With that being said, If you look above I mentioned that you can see what the aim of the program is in the output.cpp file.

what compiler errors are you getting?

the errors that I get occur in the header.h file and they are:


C[Warning] `displayStatus' initialized and declared `extern'

24 variable or field `displayStatus' declared void

24 `MaritalType' was not declared in this scope

29 expected unqualified-id before '{' token

29 expected `,' or `;' before '{' token

>>C[Warning] `displayStatus' initialized and declared `extern'

In the header file you donot have any comma's where as in the file

display.cpp

you have two inputs for the function maybe that is the reason for that.

...
// [B]MaritalType[/B] is undefined at this point
void extern displayStatus (MaritalType GrossType);
...
{);  // <-- remove that one
int extern getGross ();

OK thanks for the peices of help guys. Now i'm still having some problems which i'll show u what they are. But in the meantime, here are the changes that i made to the certain files.

FederalTaxHeader.h

#ifndef header_h
#define header_h

#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <cctype>
#include <cstdlib>
#include <fstream>


using namespace std;

namespace Federal_Taxes
{
enum GrossType {LowGross, MedGross, HighGross};
}
using namespace Federal_Taxes;
	//List of the different functions
	
void extern displayRedo ();
char extern MaritalStatus(int Single, int Married);
void extern displayStatus (char MaritalType, int GrossType);
void extern displaygross (int gross);
void extern displayInsuranceCheck ();

char extern getMaritalStatus (char & married);

int extern getGross ();

char extern response ();

void extern askMaritalStatus ();
void extern displayUsage ();
void extern displayPurpose ();
char extern getAnswer ();

void extern myLabel ( const char * assignment, const char * date,
               ostream & out);
#endif
calc.cpp

#include "FederalTaxheader.h"

 
{

    GrossType gross;
    
    if (gross < 0)
     void displayRedo ()
{
	cout << "\n You have inputted an invalid entry" 
    "would you like to use this program again? Y/N ";

}
           	if (gross < 15001)
            gross = LowGross;
				
                else if (gross < 40001)
				gross = MedGross;
                
                else if (gross > 40000)
                gross = HighGross;
                }
   
	return GrossType;
}
input.cpp

#include "FederalTaxheader.h"

char getAnswer () // answer to question so it can continue 
{
	char answer;
		
		do
		{
		cin >> answer;
		answer = toupper (answer);
		cout << " ";
		void Flush ();
		}
		while (answer != 'Y' && answer != 'N');

	return (answer);
}

int getMaritalStatus (char & married)
{   
    char maritalType
    int kidnum = 0
    do
    {
    cout << "Enter 'M' for married 'S' for single." << endl;
    
     cin >> MaritalType;
    MaritalType = toupper (MaritalType);
    while (MaritalType != 'M' || MaritalType != 'S')
    married = MaritalType;
    
if ( married == 'M' )

{

cout << "How many kids under the age of 14 do you have?" 
 "Enter a whole number only!" << endl;

cin >> kidNum;
}

return (kidNum);
}




{
	int gross;
      	do
          {     
		askgross ();
		cin >> gross;
		void Flush ();
}       while ( gross <= 0 );
		return gross;
}
main.cpp

#include "FederalTaxheader.h"

int main ()
{
    char MaritalType;
	char response;
	char Answer2; 

				displayPurpose (); //shows what the program does
          
                response (); 

			{do
			{
				
				GrossType gross; 
                
				int Low_RATE; 
				int Med_RATE;
				int High_Rate;
			do
			{
                int getgross ();
                                          
				gross = 0; // gross is set to = 0 just in case...

				
				gross = getgross ();
				

			}
			while (response == 'Y');

if married
  
   cout << "gross is income of both spouses."
   else
  cout << "gross is your income."
				
                gross = MaritalStatus (MaritalStatus, gross); 
				displayStatus (GrossType);

				displayRedo ();
				Answer2 = getAnswer ();
			}
			while (Answer2 == 'Y');
}
    myLabel ("Federal Taxes 2.0", "02/23/2008", cout);
    system("PAUSE");
    return EXIT_SUCCESS;
}
#include "FederalTaxheader.h"

double taxAmount(int numPerson, double salary, double amtdeducted, int standardExemption)
{
    double taxableIncome, totalTax, marginalIncome, marginTax;
    int tax;
    int baseTax;


taxableIncome = salary - (1500.00 * numPerson) - amtdeducted - standardExemption;
     
	if (tax >= 0 || tax <= 15000)
	{
		marginTax =.15 * taxableIncome;
		totalTax = marginTax;
	}
	else if (tax >= 15001 || tax <= 40000)
	{
		marginalIncome = taxableIncome - 15000;
		marginTax = .25 * taxableIncome;
		baseTax = 2250;
		totalTax = baseTax + marginTax;
	}
	else if (tax > 40000)
	{
		marginalIncome = taxableIncome - 40000;
		marginTax = .35 * taxableIncome;
		baseTax = 8460;
		totalTax = baseTax + marginTax;
	}

		return(totalTax);
}

The problems that I am getting seem weird. I can't seem to figure out how to resolve them. Strangely enough, they all occur in main and here they are :

In function `int main()':

11 `response' cannot be used as a function

25 invalid conversion from `int' to `Federal_Taxes::GrossType'

28 invalid conversion from `int' to `Federal_Taxes::GrossType'

34 expected `(' before "married"

41 expected primary-expression before ')' token

your not closing your statements properly with the braces that is why your getting the "In function `int main()'" error
an example is this

{do
			{
				
				GrossType gross; 
                
				int Low_RATE; 
				int Med_RATE;
				int 
High_Rate;

change it to something like this

do
{
         GrossType gross; 
                
         int Low_RATE; 
         int Med_RATE;
         int High_Rate;

}//close your if statements

also, response is returning something so when your calling it you need to assign its value to a varible i.e

/*your variable*/=response();

i'm not sure at what point i'm supposed to close the loop cuz it seems no matter where i try to close it i get a ton more errors and i'm not sure what variable to put in front of response.

there are so many loops that are not closed and am afraid i cant tell you which one to close or which one to ommit as i dont know their individual use in your program....about the variable you can create your own or use one that needs to use the value passed from the function "response()" i.e

char ans=response(); //creating a new character variable and assign it to the value passed from response

then change your loop to something like this

do
{
     int getgross ();                                     
     gross = 0;				
     gross = getgross ();				
}while (ans == 'Y');

remove the first curly bracket just before the first "do"....you need to also format your code so that it looks readable

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.