I have been trying to compile my program but i get these error messages that i can't understand. Please help. these are the error messages I am getting
error: could not convert 'MARITALSTATUS' to 'double&'
error: in passing argument 2 of 'double FEDTAX(double, double&, int, int&)'
err: In function 'double FEDTAX( double, int)':
declaration of 'MARITALSTATUS' shadows a parameter

here is the program

#include<iostream>
#include<string>
using namespace std;// ln 5

// Declaring subfunctions and other global variables.
double FEDTAX(double, double&, int, int&);
double STATETAX(double);
double LOCALTAX(double);
int MARITALSTATUS;// 

int main()
{
	string FIRSTNAME, LASTNAME;// first and last names of employee.
	char MARITALSTATUS;// Marital status of employee.
	int CENTS;
	double HOURS_WORKED, HOURLY_RATE, GROSS, NET, TAX ;
	// declaring hours worked, hourly rate, gross pay, net pay and tax as long numbers. 

	cout << "Enter  the first and last names of your employee: ";
	cin >> FIRSTNAME >> LASTNAME;

	cout << " Is " <<" " << FIRSTNAME << " " << LASTNAME << " " << "married?( Enter either 1 if married or 0 if not 	

        married): "; 
	cin >> MARITALSTATUS;

	cout << "Enter the number of hours" << " " << FIRSTNAME << " " << LASTNAME << " " << "worked this"<< " " << "week: ";
	cin >> HOURS_WORKED;

	cout << "Enter your hourly rate: ";
	cin >> HOURLY_RATE;

	CENTS= HOURS_WORKED*HOURLY_RATE*100;// Calculating pay in cents.
	GROSS= CENTS/100.0;

	cout << FIRSTNAME << " " <<  LASTNAME << endl;
	cout << HOURS_WORKED << "hours worked at $ " << HOURLY_RATE << "/ hour= $ " << GROSS << endl;
	
	TAX= FEDTAX(GROSS, MARITALSTATUS);
	
	cout << "Federal  Taxes= $ " << TAX << endl; 
	NET= GROSS-TAX;
	TAX= STATETAX(GROSS);

	cout << "State Taxes = $ " << TAX << endl;
	NET= NET-TAX;
	TAX= LOCALTAX(GROSS);

	cout << "Local Taxes =$" << TAX <<  endl;
	NET= NET-TAX;
	cout << "Net Pay =$" << NET << endl;

	return 0;
}// end main program

double FEDTAX( double GROSS, int MARITALSTATUS)
{
 int CENTS, MARITALSTATUS;
		
	   	  
    switch(MARITALSTATUS)
    	{
          case '1':
	  CENTS= 0.12*GROSS*100;
          return CENTS/100.0;
   	  break;

	  case '0':
	  CENTS= 0.18*GROSS*100;
          return CENTS/100.0;
	  break;

	}
		
 }//End FEDTAX

	
	
double STATETAX (double GROSS)
{
	int CENTS;
	CENTS= 0.0307*GROSS*100;
	return CENTS/100.0;
}// end STATETAX

.

here are the error messages


double LOCALTAX(double GROSS)
{
int CENTS;
CENTS= 0.030*GROSS*100;
return CENTS/100.0;
}// end LOCALTAX

Recommended Answers

All 7 Replies

I am sorry... here is the full program.

#include<iostream>
#include<string>
using namespace std;// ln 5

// Declaring subfunctions and other global variables.
double FEDTAX(double, double&, int, int&);
double STATETAX(double);
double LOCALTAX(double);
int MARITALSTATUS;// 

int main()
{
	string FIRSTNAME, LASTNAME;// first and last names of employee.
	char MARITALSTATUS;// Marital status of employee.
	int CENTS;
	double HOURS_WORKED, HOURLY_RATE, GROSS, NET, TAX ;
	// declaring hours worked, hourly rate, gross pay, net pay and tax as long numbers. 

	cout << "Enter  the first and last names of your employee: ";
	cin >> FIRSTNAME >> LASTNAME;

	cout << " Is " <<" " << FIRSTNAME << " " << LASTNAME << " " << "married?( Enter either 1 if married or 0 if not 	

        married): "; 
	cin >> MARITALSTATUS;

	cout << "Enter the number of hours" << " " << FIRSTNAME << " " << LASTNAME << " " << "worked this"<< " " << "week: ";
	cin >> HOURS_WORKED;

	cout << "Enter your hourly rate: ";
	cin >> HOURLY_RATE;

	CENTS= HOURS_WORKED*HOURLY_RATE*100;// Calculating pay in cents.
	GROSS= CENTS/100.0;

	cout << FIRSTNAME << " " <<  LASTNAME << endl;
	cout << HOURS_WORKED << "hours worked at $ " << HOURLY_RATE << "/ hour= $ " << GROSS << endl;
	
	TAX= FEDTAX(GROSS, MARITALSTATUS);
	
	cout << "Federal  Taxes= $ " << TAX << endl; 
	NET= GROSS-TAX;
	TAX= STATETAX(GROSS);

	cout << "State Taxes = $ " << TAX << endl;
	NET= NET-TAX;
	TAX= LOCALTAX(GROSS);

	cout << "Local Taxes =$" << TAX <<  endl;
	NET= NET-TAX;
	cout << "Net Pay =$" << NET << endl;

	return 0;
}// end main program

double FEDTAX( double GROSS, int MARITALSTATUS)
{
 int CENTS, MARITALSTATUS;
		
	   	  
    switch(MARITALSTATUS)
    	{
          case '1':
	  CENTS= 0.12*GROSS*100;
          return CENTS/100.0;
   	  break;

	  case '0':
	  CENTS= 0.18*GROSS*100;
          return CENTS/100.0;
	  break;

	}
		
 }//End FEDTAX

	
	
double STATETAX (double GROSS)
{
	int CENTS;
	CENTS= 0.0307*GROSS*100;
	return CENTS/100.0;
}// end STATETAX


double LOCALTAX(double GROSS)
{
	int CENTS;
	CENTS= 0.030*GROSS*100;
	return CENTS/100.0;
}// end LOCALTAX

You define MARITALSTATUS twice before passing to FEDTAX: first as a global int, then a local char in main. You also redefine it again in your FEDTAX function, which means the value you passed will never be used. These problems alone should be enough to cause you fits.

Also make sure that your function prototypes match the function definitions exactly.

Prototype of FEDTAX is different from the function call and function defination
prototype:

double FEDTAX(double, double&, int, int&);

defination:

double FEDTAX( double GROSS, int MARITALSTATUS)

perhaps you should change the prototype to

double FEDTAX(double, int);

Edit:Oops. Narue and I were editing simultaneously..... So it counts a useless post

thanks Narue and shiddhant3. I was wondering... the switch I applied in te function FEDTAX, it that a correct way of dealing with is. When I a.out the program. I get 0 for the value of my FEDTAX all the time.

>I get 0 for the value of my FEDTAX all the time.
I can only imagine what kind of havoc you've been wreaking with uninitialized variables. You're lucky it happens to be something sensible like, say, not reformatting your hard drive. By the way, a default case would be a fabulous addition to that switch.

Also,

CENTS= 0.0307*GROSS*100;

CENT is int and you want it to contain float values!!
These thing will surely format your hard drive. So please: FIRST THINK, THEN WRITE.

ok. I will try that. should the switch then work if the value in MARITALSTATUS is initialized and the default case is used?

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.