Double function returning the wrong product

I am trying to write a program that displays the total pay for an employee with a time and a half overtime pay. I am entering in 41 hours and a pay rate of 10, which should return $415 as the result, but for some odd reason that I do not understand it is returning $425 in the log. Could anyone help? Thank you in advance.

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
  #include <iostream>
#include <iomanip>
using namespace std;
double pay(double hours, double rate) {
    double totalGross = 0.0;
    double overTime = 0.0;
    double overTimeP = 0.0;
    if (hours > 40) {
             overTime = hours - 40;
             overTimeP = overTime * 1.5;
             hours = overTimeP + hours;
    }
    totalGross = rate * hours;
    return totalGross;
}
int main () {
    double h, r, g;
    cout << "Enter the hours then the pay rate of the employee: ";
    cin >> h >> r;
    g = pay(h, r);
    cout << "The employee's total gross is: $" << g << endl;
    system("pause");
    return 0;
}
What is line 11 supposed to accomplish?
Topic archived. No new replies allowed.