AHHHH!! i cant figure this out.

Reply

Join Date: Mar 2005
Posts: 91
Reputation: tyczj is an unknown quantity at this point 
Solved Threads: 1
tyczj tyczj is offline Offline
Junior Poster in Training

AHHHH!! i cant figure this out.

 
0
  #1
Apr 27th, 2005
i cant figure this out, here is what im suppose to do

Create a text file containing the pertinent information for the following table(not the identification row):



  1. Employee No. Department Pay Rate Exempt Hours Worked
  2. 101 41 8.11 Y 49
  3. 722 32 7.22 N 40
  4. 1273 23 5.43 Y 39
  5. 2584 14 6.74 N 45

Write a C++ program to read the employee file as parallel arrays of employee data using arrays of int, doubles and chars.. Assume that the number of employee records you have to deal with is 4 and create a payroll output file with headers as shown in the following list. The output file is to contain the following data:

a. Employee number (left justified)
b. Department
c. Pay Rate
d. Exempt
e. Hours Worked
f. Base pay (pay rate * hours worked)
g. Overtime pay
h. Total pay

Overtime pay is calculated only for nonexempt employees. An employee is exempt if ‘Y’ appears in the exempt column. Overtime is paid at time-and-a-half for all hours worked over 40. If an exempt employee works over 40 hours, that employee is only paid for 40 hours of work.

MY CODE:


  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. #define cls system("cls")
  9. #define pause system("pause")
  10.  
  11. const int CHARS_ON_LINE = 80;
  12.  
  13. const int SIZE = 4; // for number of employees
  14.  
  15. void displayInfo(int employee_num, int department, double payrate, char exempt, int hours, double basepay, double overtime, double total);
  16. double calculatepay(double basepay, double total, double overtime, double payrate);
  17.  
  18.  
  19. void main()
  20. {
  21. double payrate;
  22. double basepay;
  23. double overtime;
  24. double total;
  25.  
  26. int employee_num;
  27. int department;
  28. int hours;
  29.  
  30. char exempt = ' ';
  31.  
  32.  
  33. ifstream inFile;
  34.  
  35. ofstream outFile;
  36.  
  37.  
  38. calculatepay(payrate, basepay, overtime, total);
  39. displayInfo(employee_num, department, payrate, exempt, hours, basepay, overtime, total);
  40.  
  41. }
  42.  
  43. double calculatepay(double basepay, double total, double overtime, double payrate)
  44. {
  45. string inFileName,
  46. outFileName;
  47.  
  48. int employee_num, // employee number
  49. department, // department
  50. hours; // hours worked
  51.  
  52. char exempt; // for exempt
  53.  
  54. ifstream fin("infileLab10.txt");
  55.  
  56. fin >> employee_num;
  57. fin >> department;
  58. fin >> payrate;
  59. fin >> exempt;
  60. fin >> hours;
  61.  
  62.  
  63. basepay = payrate * hours;
  64. overtime = payrate + 1 / 2;
  65. return total = (overtime * hours > 40) + basepay;
  66.  
  67. }
  68.  
  69. void displayInfo(int employee_num, int department, double payrate, char exempt, int hours, double basepay, double overtime, double total)
  70. {
  71. ofstream fout("outfileLab10.txt");
  72.  
  73. fout << setw(15) << "Employee Number" << setw(15) << "Department" << setw(15) << "Pay Rate"
  74. << setw(15) << "Exempt" << setw(15) << "Hours Worked" << setw(15) << "Base Pay"
  75. << setw(15) << "Overtime Pay" << setw(15) << "Total Pay" << endl;
  76.  
  77. fout << left << setw(15) << employee_num << right;
  78. fout << setw(15) << department;
  79. fout << setw(15) << payrate;
  80. fout << setw(15) << exempt;
  81. fout << setw(15) << hours;
  82. fout << setw(15) << basepay;
  83. fout << setw(15) << overtime;
  84. fout << setw(15) << total;
  85.  
  86. fout << fixed << setprecision(2);
  87. }
<< moderator edit: added [code][/code] tags >>

that is what i have but i cant get it to work out. i know size has to go in there somewhere but i keep gettin errors in the math (which i know is wrong)
saying that "left operand '*' is double and can not conver to double[]"

can some one help me out im ready to scream.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 91
Reputation: tyczj is an unknown quantity at this point 
Solved Threads: 1
tyczj tyczj is offline Offline
Junior Poster in Training

Re: AHHHH!! i cant figure this out.

 
0
  #2
Apr 27th, 2005
Employee No. Department Pay Rate Exempt Hours Worked
101 | 41 | 8.11 | Y | 49
722 | 32 | 7.22 | N | 40
1273 | 23 | 5.43 | Y | 39
2584 | 14 | 6.74 | N | 45

hopefully the you can understand the table a little better this way the "|" divides the sections just incase u were wondering.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 91
Reputation: tyczj is an unknown quantity at this point 
Solved Threads: 1
tyczj tyczj is offline Offline
Junior Poster in Training

Re: AHHHH!! i cant figure this out.

 
0
  #3
Apr 27th, 2005
im also getting these error right after its starts linking

Lab10.obj : error LNK2001: unresolved external symbol "int __cdecl displayInfo(int,int,double,char,int,double,double,double)" (?displayInfo@@YAHHHNDHNNN@Z)

Lab10.obj : error LNK2001: unresolved external symbol "int __cdecl calculatepay(double,double,double,double,int)" (?calculatepay@@YAHNNNNH@Z)

Lab10.obj : error LNK2001: unresolved external symbol "int __cdecl getInfo(int,int,double,char,int)" (?getInfo@@YAHHHNDH@Z)

Debug/Lab10.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,308
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 228
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: AHHHH!! i cant figure this out.

 
0
  #4
Apr 27th, 2005
Make the function definitions match the prototypes or vice versa.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC