Enter employee's grade(A,B,C or D):f
Enter employee's grade(A,B,C or D):a
Enter the total number of working hour : 198
Normal pay 1683.00
OT pay 0.00
Total pay 1683.00
output 2:
Enter employee's grade(A,B,C or D):B
Enter the total number of working hour : 205
Normal pay 1500.00
OT pay 56.25
Total pay 1556.25
Condition:
any employee work more than 200 hours is entitled to an overtime pay of 1.5 times than normal pay. Declare 200hours and 1.5times as constants.
Keep in mind that you do not have to calculate overtime pay each time. Only on the hours above 200.
I just played with A for now and all I did was add the lineif(hour > 200) before the calculation for overtimepay. And after all the if statements I added overtimepay = 0 just to be safe. Adding the if statement to the rest of the pay grades should take care of your overtime pay problem.
When I tested the second example normal pay was not correct. Example says normal pay = 1500, but the program spit out 1537. I found that the linenormal=a*hour; hour was 205 when it should be 200 at this point. Hour having value of 205 works well in the overtimepay calculation, but not for normal pay.
That helps alot. i fixed the if(hour>200) . Thank you !
( When I tested the second example normal pay was not correct. Example says normal pay = 1500, but the program spit out 1537. I found that the linenormal=a*hour; hour was 205 when it should be 200 at this point. Hour having value of 205 works well in the overtimepay calculation, but not for normal pay. ) for this :
is there any calculation for this ? i seem cant figure out the second example calculation