posted by Soly .
I have another expression that I need help with.
If the hours worked are less than or equal to 40 return the pay as hours worked times hourly wage.
-hours*hourlywwage (this is my expression)
Otherwise return the pay as the first 40 hours worked times the hourly wage plus those hours worked over 40 times the hourly wage times 1.5.
but then when I first read the rules for the second expression, this is what I thought it would be 40*hourlywage+(hours*1.5)
could you help me out please? Thanks!
It is the number of hours over 40 *1.5 added to the 40hours * regular pay.
Example: I worked 45 hours and I make $15.00/hour, My pay would be 40hrs * $15.00 + (5 hours * $22.50)
I hope that helps
So, the expression would be 40*1.5+(hours*hourlywage)
Nevermind, I've asked my teacher and my teacher said the expression was wrong. Now, I still don't understand what to use for an expression.
You were not TOO far off, just a little bit. The first one is correct. It's the 2nd one that needs addressed.
Let's take a look at the equation you had:
You forgot to pay him for those extra hours (no hourly wage in that 1.5 times part) Plus he's not getting paid regular rate plus 1.5 times the regular rate for ALL hours. He's getting paid that 1.5 times for any hour over 40.
So it should be like this if it's over 40.
(40 * HourlyWage) + ((HoursWorked-40)* 1.5 * Hourly Wage)
In other words, you are taking 40 and multiplying it by your hourly wage.
Then you're taking the total number of hours worked and subtracting 40 (or else you'd be paying for the 40 original hours again). That will tell you how many hours more than 40 the person worked that week. (If they worked 45, you take the number of hourse (45) and subtract 40 and it leaves you with 5...he worked 5 hours overtime). Following me so far? I'm writing a lot, but trying to be detailed.
So you figure out how much overtime the person is owed by taking the 5 hours and multiplying it by 1.5 times his normal rate.
I understand. Thanxs!