So I tried to follow what you said but I get the following errors when I compile:
paycheck2.cpp:18:9: error: use of undeclared identifier 'lastName'
cin >> lastName;
^
paycheck2.cpp:21:9: error: use of undeclared identifier 'rate'
cin >> rate;
^
paycheck2.cpp:27:4: error: use of undeclared identifier 'day'
day = "Monday";
^
paycheck2.cpp:31:4: error: use of undeclared identifier 'day'
day = "Tuesday";
^
paycheck2.cpp:35:4: error: use of undeclared identifier 'day'
day = "Wednesday";
^
paycheck2.cpp:39:4: error: use of undeclared identifier 'day'
day = "Thursday";
^
paycheck2.cpp:43:4: error: use of undeclared identifier 'day'
day = "Friday";
^
paycheck2.cpp:46:44: error: use of undeclared identifier 'day'
cout << "Enter the hours worked for " << day << ": " << endl;
^
paycheck2.cpp:47:10: error: use of undeclared identifier 'hours'
cin >> hours[i];
^
paycheck2.cpp:49:29: error: use of undeclared identifier 'hours'
sumofhours = sumofhours + hours[i];
^
paycheck2.cpp:58:5: error: use of undeclared identifier 'sumofhours'
if(sumofhours > 40)
^
paycheck2.cpp:60:14: error: use of undeclared identifier 'sumofhours'
overtime = sumofhours - 40;
^
paycheck2.cpp:61:16: error: use of undeclared identifier 'sumofhours'
regularpay = sumofhours - overtime;
^
paycheck2.cpp:63:3: error: use of undeclared identifier 'pay'
pay = (overtime * (1.5 * rate)) + (regularpay * rate);
^
paycheck2.cpp:63:28: error: use of undeclared identifier 'rate'
pay = (overtime * (1.5 * rate)) + (regularpay * rate);
^
paycheck2.cpp:63:51: error: use of undeclared identifier 'rate'
pay = (overtime * (1.5 * rate)) + (regularpay * rate);
^
paycheck2.cpp:65:10: error: use of undeclared identifier 'sumofhours'
else if(sumofhours !> 40)
^
paycheck2.cpp:67:3: error: use of undeclared identifier 'pay'
pay = sumofhours * rate;
^
paycheck2.cpp:67:9: error: use of undeclared identifier 'sumofhours'
pay = sumofhours * rate;
Here is my code:
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
|
#include <iostream>
#include <string>
using namespace std;
struct Employee
{
string lastName;
double hourse[5];
double rate, pay;
};
void initialize(Employee& emp)
{
double sumofhours;
cout << "Enter the last name of the employee: " << endl;
cin >> lastName;
cout << "Enter the rate of pay for this employee: " << endl;
cin >> rate;
for(int i = 1; i < 6; i++)
{
if(i == 1)
{
day = "Monday";
}
else if(i == 2)
{
day = "Tuesday";
}
else if(i == 3)
{
day = "Wednesday";
}
else if(i == 4)
{
day = "Thursday";
}
else if(i == 5)
{
day = "Friday";
}
cout << "Enter the hours worked for " << day << ": " << endl;
cin >> hours[i];
sumofhours = sumofhours + hours[i];
}
}
void compute(Employee& emp)
{
double overtime;
double regularpay;
if(sumofhours > 40)
{
overtime = sumofhours - 40;
regularpay = sumofhours - overtime;
pay = (overtime * (1.5 * rate)) + (regularpay * rate);
}
else if(sumofhours !> 40)
{
pay = sumofhours * rate;
}
return pay;
}
void result(Employee emp)
{
cout << "Employee " << lastName << "'s " << "pay is " << pay;
}
int main()
{
Employee * pointer = new Employees[4];
initialize(Employees);
for(int i = 0; i < 5; i++)
{
compute(Employees[i]);
result(Employees[i]);
}
return 0;
}
|
I think my problem is with the parameters of the functions. I really don't understand what to put in there.