I NEED HELP!! Payroll Array Program wont compile.

My Program won't compile and I've been struggling with this for about a day now I really need help. I don't know what to do.

ERRORS:

In function 'void ProcessPayRoll(const int*, const int*, const float*, int, const float*, const float*, int)':
96:35: error: invalid conversion from 'int' to 'int*' [-fpermissive]
96:51: error: cannot convert 'const float' to 'float*' for argument '2' to 'float ComputeWages(int*, float*)'
98:53: error: cannot convert 'const float' to 'const float*' for argument '2' to 'int FindTaxLevel(float, const float*, int)'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//------------------------------------------------------------------------

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

const int MAX_EMP = 25;
const int MAX_TAX = 5;
const float TAX_1000 = .035;
const float TAX_2000 = .06;
const float TAX_4000 = .085;
const float TAX_LUX = .12;
const int MAX_OVERTIME = 60;
const int MAX_NORMAL_HOURS = 40;

void GetTaxTable(float taxable[], float taxrate[], int& numTax);
void GetEmpHours(int empid[], int hours[], float hourlyrate[], int& numEmp);
void PrintHeader(int numEmp);
void ProcessPayRoll(const int empid[], const int hours[], 
                    const float hourlyrate[], int numEmp, 
                    const float taxable[], const float taxrate[],
                    int numTax);
bool OverHoursLimit(int hours);
int FindTaxLevel(float wages, const float taxable[], int size);
float ComputeWages(int hours[], float hourlyrate[]);
void PrintEmpWages(int empid, float wages, float rate, float netpay);

int main ()
{
   while(!cin.eof())
   {
   float taxable[MAX_TAX], taxrate[MAX_TAX], hourlyrate[MAX_EMP];
   int empid[MAX_EMP], hours[MAX_EMP], numEmp = 0, numTax = 0;
   cout << "Enter the number of levels for the tax table:" << endl;
   cin >> numTax;
   GetTaxTable(taxable, taxrate, numTax);
   cout << "Enter the number of empliees to process:" << endl;
   cin >> numEmp;
   GetEmpHours(empid, hours, hourlyrate, numEmp);
   PrintHeader(numEmp);
   ProcessPayRoll(empid, hours, hourlyrate, numEmp, taxable, taxrate, numTax);
   }
   return 0;
}

void GetTaxTable(float taxable[],float taxrate[], int& numTax)
{
   int length = numTax;
   for (int index = 0; index < length; index++)
   {
      cout << "Enter taxable wages and tax rates:" << endl;
      cin >> taxable[index];
      cin >> taxrate[index];
   }
}

void GetEmpHours(int empid[], int hours[], float hourlyrate[], int& numEmp)
{
   int size = numEmp;
   for (int k = 0; k < size; k++)
   {
      cout << "Enter employee ID, hours and hourly rate:" << endl;
      cin >> empid[k];
      cin >> hours[k];
      cin >> hourlyrate[k];
   }
}

void PrintHeader(int numEmp)
{
   cout << "Employee Payroll with" << numEmp << "entries./n" << endl;
   cout << setw(6) << "EmpID" << setw(8) << "Gross Pay" 
        << setw(8) << "Tax Rate" << setw(8) << "Net Pay" << endl;
   cout << "------" << setw(9) << "---------" << setw(8)
        << "---------" << setw(8) << "---------" << endl;
}

void ProcessPayRoll(const int empid[], const int hours[], 
                    const float hourlyrate[], int numEmp, 
                    const float taxable[], const float taxrate[],
                    int numTax)
{
   float wages, taxes = 0.0, netpay = 0.0;
   int index = 0;
   for(int n = 0; n < numEmp; n++)
   {
      wages = ComputeWages(hours[n], hourlyrate[n]);
      netpay = wages - taxes;
      index = FindTaxLevel(wages, taxable[n], numTax);
      taxes = wages * taxrate[index];
      PrintEmpWages(empid[n],wages,hourlyrate[n],netpay);
   }
}

bool OverHoursLimit(int hours)
{
   if (hours > MAX_OVERTIME)
      return true;
   else 
      return false;
}

int FindTaxLevel(float wages, const float taxable[], int size)
{
   for (int i = 0; i < size; i++)
      if (taxable[i] <= wages)
         return i;
   return -1;
}

float CompeterWages(int hours[], float hourlyrate[])
{
   float grossPay = 0.0;
   int overTime = 0;
   for (int h = 0; h < MAX_EMP; h++)
   {
      if (OverHoursLimit(hours[h]) == true)
      cout << "Abnormal overtime hours! Unable to process!!" << endl;
      if (hours[h] > MAX_NORMAL_HOURS)
      {
         overTime = hours[h] - MAX_NORMAL_HOURS;
         grossPay = (overTime * hourlyrate[h] * 1.5) + (MAX_NORMAL_HOURS * hourlyrate[h]);
      }
      else
         grossPay = hours[h] * hourlyrate[h];
   }
   return grossPay;
}

void PrintEmpWages(int empid, float wages, float rate, float netpay)
{
   cout << setw(6) << empid 
        << setw(3) << wages 
        << setw(5) << rate
        << setw(5) << netpay
        << endl;
}
Function prototype expects 2 parameters, an int array and a float array:
float ComputeWages(int hours[], float hourlyrate[]);

Function call provides 2 parameters, an int and a float:
wages = ComputeWages(hours[n], hourlyrate[n]);

Conclusion: function call does not match function definition.

Same for your other error. You should also look into const correctness. Either remove all the const in the parameters of ProcessPayRoll, or else add const to all the parameters of all the functions that ProcessPayRoll calls.
Unfortunately the parameters are give this is an assignment, could you help me get around that at all, even when I tried to do that it gives me errors of nothing working.
I changed the prototype to
1
2
float ComputeWages(int hours[], float hourlyrate[]);
 


Now its giving me:
/tmp/ccsQRvj1.o: In function `ProcessPayRoll(int const*, int const*, float const*, int, float const*, float const*, int)':
:(.text+0x79b): undefined reference to `ComputeWages(int, float)'
collect2: error: ld returned 1 exit status


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void ProcessPayRoll(const int empid[], const int hours[], 
                    const float hourlyrate[], int numEmp, 
                    const float taxable[], const float taxrate[],
                    int numTax)
{
   float wages, taxes = 0.0, netpay = 0.0;
   int index = 0;
   for(int n = 0; n < numEmp; n++)
   {
      wages = ComputeWages(hours[n], hourlyrate[n]);
      netpay = wages - taxes;
      index = FindTaxLevel(wages, taxable, numTax);
      taxes = wages * taxrate[index];
      PrintEmpWages(empid[n],wages,hourlyrate[n],netpay);
   }
}


Here is the function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
float CompeterWages(int hours, float hourlyrate)
{
   float grossPay = 0.0;
   int overTime = 0;
      if (OverHoursLimit(hours) == true)
      cout << "Abnormal overtime hours! Unable to process!!" << endl;
      if (hours > MAX_NORMAL_HOURS)
      {
         overTime = hours - MAX_NORMAL_HOURS;
         grossPay = (overTime * hourlyrate * 1.5) + (MAX_NORMAL_HOURS * hourlyrate);
      }
      else
         grossPay = hours * hourlyrate;
   return grossPay;
}
I don't see how you changed your function prototype? It's exactly the same as in your first post. Also, you've been naming your function wrong.
float ComputeWages(int hours[], float hourlyrate[]);
.
float CompeterWages(int hours, float hourlyrate)
I fixed it thank you!
Topic archived. No new replies allowed.