469,904 Members | 2,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

confusing error messages

1
i have gone through my c++ program and i keep getting the same error messages:
error C2065: 'indata' : undeclared identifier
error C2228: left of '.open' must have class/struct/union
my program looks like this. if someone could help me fix this problem i will be extremely thankfull

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <fstream>
  5.  
  6.  
  7. using namespace std;
  8. string employeeFirst, employeeLast;
  9. double gross;
  10. double federal, state, ss, med, pension, health, net;
  11.  
  12.  
  13. int main()
  14. {
  15.  
  16. cout << "what is the Employees Name" << endl;
  17. cin >> employeeFirst >> employeeLast;
  18. cout << "What is the Employees Gross Pay" << endl;
  19. cin >> gross;
  20.  
  21. cout << fixed << showpoint << setprecision (2);
  22. cout << setfill ('.');
  23.  
  24. ifstream infile;
  25. indata.open ("PayrollTaxes");
  26. federal = (gross * .15);
  27. indata >> left >> setw(22) >> "Federal Tax" >> right >> setw(14) >> federal >> endl;
  28. state = (gross * .035);
  29. indata >> left >> setw(22) >> "State Tax" >> right >> setw(14) >> state >> endl;
  30. ss = (gross * .0575);
  31. indata >> left >> setw(22) >> "Social Security Tax" >> setw(14) >> ss >> endl;
  32. med = (gross * .0275);
  33. indata >> left >> setw(22) >> "Medicair/Medicaid Tax" >> setw(14) >> med >> endl;
  34. pension = (gross * .05);
  35. indata >> left >> setw(22) >> "Pension Plan" >> setw(14) >> pension >> endl;
  36. health = 75.00;
  37. indata >> left >> setw(22) >> "Health Insurance" >> setw(14) >> health >> endl;
  38. net = (gross-(federal + state + ss + med + pension + health));
  39. indata >> left >> setw(22) >> "Net Pay" >> setw(14) >> net >> endl;
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.     return 0;
  47. }
Oct 5 '07 #1
2 1881
r035198x
13,262 8TB
i have gone through my c++ program and i keep getting the same error messages:
error C2065: 'indata' : undeclared identifier
error C2228: left of '.open' must have class/struct/union
my program looks like this. if someone could help me fix this problem i will be extremely thankfull

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>


using namespace std;
string employeeFirst, employeeLast;
double gross;
double federal, state, ss, med, pension, health, net;


int main()
{

cout << "what is the Employees Name" << endl;
cin >> employeeFirst >> employeeLast;
cout << "What is the Employees Gross Pay" << endl;
cin >> gross;

cout << fixed << showpoint << setprecision (2);
cout << setfill ('.');

ifstream infile;
indata.open ("PayrollTaxes");
federal = (gross * .15);
indata >> left >> setw(22) >> "Federal Tax" >> right >> setw(14) >> federal >> endl;
state = (gross * .035);
indata >> left >> setw(22) >> "State Tax" >> right >> setw(14) >> state >> endl;
ss = (gross * .0575);
indata >> left >> setw(22) >> "Social Security Tax" >> setw(14) >> ss >> endl;
med = (gross * .0275);
indata >> left >> setw(22) >> "Medicair/Medicaid Tax" >> setw(14) >> med >> endl;
pension = (gross * .05);
indata >> left >> setw(22) >> "Pension Plan" >> setw(14) >> pension >> endl;
health = 75.00;
indata >> left >> setw(22) >> "Health Insurance" >> setw(14) >> health >> endl;
net = (gross-(federal + state + ss + med + pension + health));
indata >> left >> setw(22) >> "Net Pay" >> setw(14) >> net >> endl;






return 0;
}
1.) Use code tags when posting code.
2.) This belongs in the C++ forum not in the challenges forum.
Oct 6 '07 #2
You never declared indata. You declared infile, but not indata.
Oct 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by lkrubner | last post: by
10 posts views Thread by Brian Conway | last post: by
3 posts views Thread by Maya Sam | last post: by
2 posts views Thread by FutureShock | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.