Hey guys, you all have helped me loads in the past and I've been appreciative of it all. Before I post here, I try to work out as much as possible rather than posting a small piece of code and then asking for help. This program should be extremely simple to do. Unfortunately I can't think of the exact math on it. I definitely shouldn't be taking a programming class if I'm not good at math, but sometimes I'm able to get by haha! Anyway, I was wondering if there was a better way to write this program as well as if you could give me advice on the math that's involved in the conditional statements. I've got the rough idea of how the program works, but it could definitely use some polishing. My C++ skills are rather lacking to say the least, but I'm definitely trying! Any help, would be greatly appreciated it.
------------ Weekly Salary Program ------------------------------
Um.... if you work over 40 hours... you're paid time and and a half for all the hours you have worked? Surely it should only be for the hours you have worked after 40?
If hours over 40 then get difference between 40 and hours worked put into 'overtime worked' variable.
calculate wages for 40 hours as normal. store in varX
hourly_wage * overtime_worked * 1.5. add product to varX
Haha! Stupid me! That's one thing that I'm missing on there. Are there any other tricks that I could add to this program? Other than the mistake on the math.
If anyone is still viewing this and scratching their head, I did manage to get the math right for the overtime. Unfortunately I don't have the right math for the minutes. I need to be able to calculate both the hours and minutes into this program, otherwise the program will not work properly. Since the person worked 39 hours and 30 minutes, the hourly wage should be divided in half since he's getting paid for half the hour, but what if it was 15 minutes or 20 minutes or so on? I'm trying to figure out how to code that part in. That should be the easy part. The hard part is when I need to round it to the cent. For example, if the answer is 421.265, the rounded part should be 421.27.. Here's the current code that I've got thus far.
-------------- Weekly Salary Program ----------------------------