I'm not very good at Python as you can tell from my earlier posts.
I'm trying to write a payroll program that gets the input from the user of how many hours worked and the hourly rate and calculates the total wages for the week. It also has to figure over-time-hours by paying anything over 40 hours time-and-a-half(* 1.5). I want to set it up into four functions though. So, the first function would ask for the hours and pay rate. The second would calculate the regular hours and overtime hours. The third would calculate regular pay and overtime pay and the total pay. Then the fourth(main) would display the info something like this....
Pay rate $10.00
Regular Hours 40
Overtime hours 20
Regular pay $400.00
Overtime pay $300.00
Total Pay $700.00
(Just example numbers)
This is what I have so far.
def hours():
hours = input("How many hours did you work?:")
return hours
def payrate():
payrate = input("How much is the payrate?:")
return payrate
def calchours(pr,h):
if h > 40:
overtime = pr * h *1.5
print overtime
elif h < 40:
reg = pr * h
print reg
def main():
hrs = hours()
pyr = payrate()
calchours (pyr, hrs)
main()
I'm not sure on how to handle the input of hours and payrate in the same function or how to display all the information in main. I definitely need it all organized within four functions though. If someone could help make sense of this that would be exteremely generous.
Thanks for your time.