Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

token error

I'm assuming I know what I programmer defined function is .  

I get an error saying:

C2239: unexpected token '{' following declaration of 'deduction'
 
Here's my code
// Calculation function

double deduction
{

//variable definitions
      double sTaxAmt;
      double fTaxAmt;
      double mDedAmt;
      const double sTaxPct = .08;      
      const double fTaxPct = .32;
      const double miscPct = .20;
      deduction = (sTaxPct + fTaxPct + miscPct);

}//end calculation function

0
nationnon
Asked:
nationnon
  • 4
  • 2
1 Solution
 
proskigCommented:

double deduction()!!!!
{

//variable definitions
double sTaxAmt;
double fTaxAmt;
double mDedAmt;
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct); !!!!!

}//end calculation function

It should help
0
 
nationnonAuthor Commented:
Adjusted points from 20 to 30
0
 
nationnonAuthor Commented:
what does this mean ???

error C2659: '=' : overloaded function as left operand

it points to this

deduction = (sTaxPct + fTaxPct + miscPct);






0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
proskigCommented:
deduction token is not the result of a function - it is a pointer to the function. So it cannot assign to function numeric value. My code (return ...) should do what you intended to do.
0
 
nationnonAuthor Commented:
Adjusted points from 30 to 40
0
 
nationnonAuthor Commented:
I got four more warnings #include <iostream.h>


void main ()

// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
double deduction;



//User entered information

      cout <<"Enter first employee's last name: ";
      cin >> fElastName;
      cout <<"Enter first employee's first name: ";
      cin >> fEfirstName;
      cout <<"Enter first employee's pay rate: ";
      cin >> fErate;
      cout <<"Enter first employee's hours: ";
      cin >> fEhrs;
      cout << "Enter second employee's last name: ";
      cin >> sElastName;
      cout << "Enter second employee's first name: ";
      cin >> sEfirstName;
      cout << "Enter second employee's hours: ";
      cin >> sEhrs;
      cout << "Enter second employee's rate: ";
      cin >> sErate;

// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay - deduction;
sEnPay = sEgPay - deduction;

// ask user which employee they want to view
int nEmployee;

do
{
  cout << "Choose Employee 1 or 2: ";
  cin >> nEmployee;
}
while(nEmployee<=1 || nEmployee>=2);

if (nEmployee<=1)
      cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;

if (nEmployee>=2)
      cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;      

}

//Main calculations



//End of main function

// Calculation function

double deduction()                  
{

//variable definitions
double sTaxAmt;
double fTaxAmt;
double mDedAmt;
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);

}//end calculation function



0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now