# Arup Guha
# 10/13/2020
# Solution to COP 2930 Program 6, Part C: Payment Calculator.

# Pre-conditions: payPerHour is a positive floating pt 
#  number representing the pay per hour. regWorkWeek
#  represents the number of hours in a regular work week
#  (int). hoursWorked is the number of hours the employee
#  worked (int).
# Post-condition: Returns the regular pay for the employee.
def regularPay(payPerHour, regWorkWeek, hoursWorked):

    # Here we multiply by hours worked.
    if hoursWorked <= regWorkWeek:
        return payPerHour*hoursWorked

    # If we get here, they get full pay no matter how much they worked.
    return payPerHour*regWorkWeek

# Pre-conditions: payPerHour is a positive floating pt 
#  number representing the pay per hour. regWorkWeek
#  represents the number of hours in a regular work week
#  (int). hoursWorked is the number of hours the employee
#  worked (int). overtimeRate is the multiplicative rate
#  for overtime pay.
# Post-condition: Returns the overtime pay for the employee.
def overtimePay(payPerHour, regWorkWeek, hoursWorked, overtimeRate):
    
    # Can't get over time if you didn't work extra hours.
    if hoursWorked <= regWorkWeek:
        return 0

    # Here we take extra hours and multiply by the improved pay rate.
    return (hoursWorked-regWorkWeek)*payPerHour*overtimeRate

# Our main program is here.
def main():

    # Get user input.
    payPerHour = float(input("How much (in dollars) are you paid per hour?\n"))
    regWeek = int(input("How many hours in the regular work week?\n"))
    overtimeRate = float(input("What is the overtime rate?\n"))
    numWeeks = int(input("How many weeks are you working?\n"))

    # Total pay accumulator.
    total = 0

    # Go through each week.
    for week in range(1,numWeeks+1):

        # Get hours worked in this week.
        hours = int(input("How many hours did you work in week "+str(week)+"?\n"))

        # Calculate both separately so we can print.
        regPay = regularPay(payPerHour, regWeek, hours)
        overPay = overtimePay(payPerHour, regWeek, hours, overtimeRate)
        weekPay = regPay + overPay

        # Lots to print so split it.
        print("Week ", week," regular pay = $", regPay,", overtime pay = $", sep="", end="")
        print(overPay, ", total pay = $", weekPay, ".", sep="")

        # Update total accumulator.
        total += weekPay

    # Ta da!
    print("Total pay for ",numWeeks," weeks = $", total,".", sep="")

# Run it.
main()
