944,147 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2092
  • C++ RSS
Apr 27th, 2005
0

AHHHH!! i cant figure this out.

Expand Post »
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):



C++ Syntax (Toggle Plain Text)
  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:


C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
tyczj is offline Offline
91 posts
since Mar 2005
Apr 27th, 2005
0

Re: AHHHH!! i cant figure this out.

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.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
tyczj is offline Offline
91 posts
since Mar 2005
Apr 27th, 2005
0

Re: AHHHH!! i cant figure this out.

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.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
tyczj is offline Offline
91 posts
since Mar 2005
Apr 27th, 2005
0

Re: AHHHH!! i cant figure this out.

Make the function definitions match the prototypes or vice versa.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC