How can I create a pay rate function in my class?

I need to create a function that calculates pay defined in a class. Upon compilation, I get errors saying that I did not declare my print or pay function. How can I fix this and my pay function, and display the pay rate in the main function?

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
  class Employee{
      private:
         string firstName, lastName, SSN;
         double total, payRate;
      public:
         void setName(string f, string l){
              firstName = f;
              lastName = l;    
              };
         void setSSN(string ssNum){
              SSN = ssNum;
              };
         void setPay(int pay){
              pay = payRate;
              };
         string getfN(){
                return firstName;
                };
         string getlN(){
                return lastName;
                };
         string getsNum(){
                return SSN;
                };
         void printEmployee(){
              cout << "Name: " << firstName << " " << lastName << endl;
              cout << "SSN: " << SSN << endl;
              cout << "Week's total earnings: " << total << endl;
              };
        int calculatePay(int hours){
                         double payRate, total;
                         int overtime, hoursWorked;
                         payRate = 10;
                         if (hoursWorked > 40){
                                         overtime = hoursWorked - 40;
                                         total = (40 * 10) + (overtime * 5);
                                         }
                         else {
                             total = hoursWorked * 10;
                             }
                                          
                         return total;
                         } 
};

int main(int argc, char *argv[])
{
    string f, l, ssn;
    int hours, pay;
    cout << "First name: ";
    Employee c1;
    cin >> f;
    cout << "Last name: ";
    cin >> l;
    c1.setName(f, l);
    cout << "SSN: ";
    cin >> ssn;
    c1.setSSN(ssn);
    cout << "Hours worked: ";
    cin >> hours;
    c1.setHours(hours);
    pay = calculatePay(hours);
    printEmployee(c1);

    
    system("PAUSE");
    return EXIT_SUCCESS;
}
From what you say, you just need to implement the print and pay methods of Employee like you did with the rest of the functions.
Well I got it to run. I commented the lines where I know problems are arising.
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
class Employee{
      private:
         string firstName, lastName, SSN;
         double total, payRate;
      public:
         void setName(string f, string l){
              firstName = f;
              lastName = l;    
              };
         void setSSN(string ssNum){
              SSN = ssNum;
              };
         void setPay(int pay){
              pay = payRate;
              };
         string getfN(){
                return firstName;
                };
         string getlN(){
                return lastName;
                };
         string getsNum(){
                return SSN;
                };
         void printEmployee(){
              cout << "Name: " << firstName << " " << lastName << endl;
              cout << "SSN: " << SSN << endl;
              //cout << "Week's total earnings: " << total << endl;
              };
        /*int calculatePay(int hours){
                         double payRate, total;
                         int overtime, hoursWorked;
                         payRate = 10;
                         if (hoursWorked > 40){
                                         overtime = hoursWorked - 40;
                                         total = (40 * 10) + (overtime * 5);
                                         }
                         else {
                             total = hoursWorked * 10;
                             }
                                          
                         return total;
                         }*/
};

int main(int argc, char *argv[])
{
    string f, l, ssn;
    int hours, pay;
    cout << "First name: ";
    Employee c1;
    cin >> f;
    cout << "Last name: ";
    cin >> l;
    c1.setName(f, l);
    cout << "SSN: ";
    cin >> ssn;
    c1.setSSN(ssn);
    /*cout << "Hours worked: ";
    cin >> hours;
    c1.setHours(hours);
    pay = calculatePay(hours);*/
    c1.printEmployee();

    
    system("PAUSE");
    return EXIT_SUCCESS;
}
It would really be great if someone could help me with this. I have a deadline to submit it by.
You don't have your print or pay methods defined. You need to define them, then your code should work.
Topic archived. No new replies allowed.