Skip to main content
Tweeted twitter.com/StackCodeReview/status/1465606543433474051
Post Reopened by holroy, 301_Moved_Permanently, CommunityBot, CodeYogi, IEatBagels
edited tags
Link
IEatBagels
  • 12.7k
  • 3
  • 48
  • 99
Added a little text to clarify that review is for this version, but that the OP is aiming for calculating multiple payrolls.
Source Link
holroy
  • 11.8k
  • 1
  • 27
  • 59

thisThis is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner.

def main():

    hours, rate = inputData()
    normal_hours, overtime_hours, overtime  = computePay (hours,rate)
    regular, total_pay  = preovertime_hours (hours, rate, overtime)
    displayPay  (rate, normal_hours, overtime_hours, regular, overtime, total_pay)


def inputData():

    name = raw_input('Name of employee: ')    
    hours = float (input('Now enter the hours worked please:'))
    rate = float (input('Now enter the pay rate:'))


    return hours, rate

def computePay (hours,rate):

    if hours < 40:
        normal_hours = hours
        overtime_hours = 0
    else:
        normal_hours = 40
        overtime_hours = hours - 40

    if hours > 40:
        overtimerate = 1.5 * rate
        overtime = (hours-40) * overtimerate
    else:
        overtime = 0

    return normal_hours, overtime_hours, overtime

def preovertime_hours (hours, rate, overtime):

    regular = hours * rate
    total_pay = regular
    return regular, total_pay


def displayPay (rate, normal_hours, overtime_hours, regular, overtime, total_pay):
    
    print ("The amount to be paid to in this pay period is $" + format(total_pay, '.2f'))
    
main()

this is a calculator I'm working on. The goal is to calculate multiple payrolls before selecting to end the program. PSA: I'm a beginner.

def main():

    hours, rate = inputData()
    normal_hours, overtime_hours, overtime  = computePay (hours,rate)
    regular, total_pay  = preovertime_hours (hours, rate, overtime)
    displayPay  (rate, normal_hours, overtime_hours, regular, overtime, total_pay)


def inputData():

    name = raw_input('Name of employee: ')    
    hours = float (input('Now enter the hours worked please:'))
    rate = float (input('Now enter the pay rate:'))


    return hours, rate

def computePay (hours,rate):

    if hours < 40:
        normal_hours = hours
        overtime_hours = 0
    else:
        normal_hours = 40
        overtime_hours = hours - 40

    if hours > 40:
        overtimerate = 1.5 * rate
        overtime = (hours-40) * overtimerate
    else:
        overtime = 0

    return normal_hours, overtime_hours, overtime

def preovertime_hours (hours, rate, overtime):

    regular = hours * rate
    total_pay = regular
    return regular, total_pay


def displayPay (rate, normal_hours, overtime_hours, regular, overtime, total_pay):
    
    print ("The amount to be paid to in this pay period is $" + format(total_pay, '.2f'))
    
main()

This is a calculator I'm working on. The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context. PSA: I'm a beginner.

def main():

    hours, rate = inputData()
    normal_hours, overtime_hours, overtime  = computePay (hours,rate)
    regular, total_pay  = preovertime_hours (hours, rate, overtime)
    displayPay  (rate, normal_hours, overtime_hours, regular, overtime, total_pay)


def inputData():

    name = raw_input('Name of employee: ')    
    hours = float (input('Now enter the hours worked please:'))
    rate = float (input('Now enter the pay rate:'))


    return hours, rate

def computePay (hours,rate):

    if hours < 40:
        normal_hours = hours
        overtime_hours = 0
    else:
        normal_hours = 40
        overtime_hours = hours - 40

    if hours > 40:
        overtimerate = 1.5 * rate
        overtime = (hours-40) * overtimerate
    else:
        overtime = 0

    return normal_hours, overtime_hours, overtime

def preovertime_hours (hours, rate, overtime):

    regular = hours * rate
    total_pay = regular
    return regular, total_pay


def displayPay (rate, normal_hours, overtime_hours, regular, overtime, total_pay):
    
    print ("The amount to be paid to in this pay period is $" + format(total_pay, '.2f'))
    
main()
Police shut me down, had to wewrite question
Source Link
Aaron
  • 357
  • 1
  • 4
  • 11
Loading
Post Closed as "Not suitable for this site" by Jamal
Source Link
Aaron
  • 357
  • 1
  • 4
  • 11
Loading