It works, assuming the employee puts in at least 40 hours per week. Lets pretend our employee takes a day off, or is only part time. Using that formula for the calculation, he would still be paid for 40 hours, regardless of how much time he actually out in. . Something like this may do you better:
grossPay = (workhours * rateOfPay) + ((workHours-40) * 1.5);
You'll probably need to add some additional logic in there so you don't end up adding negative numbers to the gross pay.
Another issue you may want to think about is how you are awarding overtime. Correct me if I'm wrong, but dont most employers calculate overtime in daily increments?
Here is a scenario. Lets pretend our employee works mon-wensday normal hours. On Thursday he works 3 hours overtime, and takes off Friday. With your current pay stricture, he wouldn't be paid extra for that overtime he put in on Thursday. Of course, the method for awarding overtime is completely up to you.