Please write your response in Python. Write a program that has four functions th
ID: 3761285 • Letter: P
Question
Please write your response in Python.
Write a program that has four functions that do the following: A main() function that has a loop that calls the other three functions until a user enters ‘n’ in response to the question, “Do you need more payroll calculations? (y/n) ” An inputData() function to input employee name, hours worked and pay rate A computePay() function to calculate the amount to be paid based on the formula: For the first 40 hours, the rate is the given rate; For hours over 40, the rate is 1.5 times the given rate An displayPay() function to output the name and the amount to be paid. Example: The amount to be paid to John Doe in this pay period is $754.80 Write a statement at the bottom of the program to call the main() function.
Explanation / Answer
def inputData():
name = input()
hours = input()
payRate = input()
amount = computePay(hours,payRate)
displayPay(name,amount)
def computePay(hours,payRate):
if hours <= 40 :
return hours*payrate;
else :
return 40*payRate+((hours-40)*1.5*payRate;
def displayPay(name,amount):
print "The amount to be paid to " + name + " in this pay period is $" + amount +"."
def main():
while true:
print "Do you need more payroll calculations? (y/n)"
if input() == 'y':
inputData()
else :
break;
if __name__ == "__main__":
main()