Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will allow a user to enter working hours and pay rates for

ID: 3537729 • Letter: W

Question

Write a program that will allow a user to enter working hours and pay rates for employees:

1) The program should prompt the user for three elements of information for each employee:

Last Name
Pay Rate
Hours Worked
2) The program should allow the user to enter as many employees as they wish. Tell you user how to either continue entering data, or to quit.

3) If a person works over 40 hours, those hours are considered over time hours and need to be paid at 1.5 times the pay rate

4) After each entry, display the Name and pay for that employee

5) Keep a running total of regular pay, overtime pay, regular hours and overtime hours %u2013 at the end of the program you will need to display the total payroll amounts.

No two programs should look alike, this is an individual project and copying and/or plagiarism will result in a zero and/or withdrawal from the class. Simply changing variable names and/or structure does not count as an individual program. No exceptions.

Requirements:

1) Must contain a main function %u2013 this function will be responsible for controlling the loop, data entry, displaying the total pay for a particular person and accumulation

2) Must contain a value returning function that returns the regular pay for a person

3) Must contain a value returning function that returns the overtime pay for a person

4) Must contain a separate print function for printing totals

5) Do not use global variables, except the overtime multiplier can be a constant if you wish (the 1.5)

6) All dollar amount should be formatted properly with dollar sign, commas, and two decimal points

7) You should have at least one instance of decision logic (if/then)

Outputs:

While you loop your program should prompt

Enter Last Name: <Jones>

Enter Pay Rate: <8.00>

Enter Hours: <43>

(Assume they entered Jones 8.00 43)

Call your functions and then you should display something like this:

Jones: $96.00

Ask if they%u2019d like to enter more or quit

%u2026.

Then, once the user quits, you will need to display the totals:

(%u2026 this is just an example%u2026.)

Total Regular Hours: 765

Total Overtime Hours: 65

Total Regular Pay $76,001.50

Total Overtime Pay $560.71

I am having problems with my program not displaying the Final calculation, it just shows 0's for the results. Also I cant seem to get the dollar format to put commas where needed in the dollar amounts. Can anyone please help?

My program is listed below. Need as soon as possible. Please. Thanks in advance.

reghours = 0
overtime = 0
payrate = 0.0
regpay = 0.0
overpay = 0.0
totalpay = 0.0


def main():

    totalreghours = 0
    totaloverhours = 0
    totalregpay = 0.0
    totaloverpay = 0.0

# Variable to control the loop.

    another = 'y'

# Process another employee.

    while another == 'y':

# Get employee info input

        name = input('Enter Employees Last Name: ')

        payrate = float(input('Enter Employees Pay Rate(Per Hour): $'))

        hours = int(input('Enter Hours Worked: '))

        calc_hours(hours)

        calc_pay(reghours,overtime,payrate)


# Summary of employee after information was entered

        print('Mr/Mrs',name, 'has a gross pay of, $',format(payrate*hours, '.2f'))

# Asking user if they want to enter more employee info

        totalreghours = reghours

        totaloverhours = totaloverhours + overtime

        totalregpay = totalregpay + regpay

        totaloverpay = totaloverpay + overpay

        another = input('Do you want to enter another employees info? (Enter "y" for yes or "n" for no): ')


# Call to print totals

    else:

        totals(totalreghours,totaloverhours,totalregpay,totaloverpay)

def calc_hours(hours):

    if hours < 40:

        reghours = hours

        overtime = 0

    else:

        reghours = 40

        overtime = hours - 40

    return reghours, overtime

def calc_pay(reghours,overtime,payrate):

    regpay = reghours * payrate

    overpay = overtime * (payrate * 1.5)

    totalpay = regpay + overpay

    return regpay, overpay, totalpay

def totals(totalreghours,totaloverhours,totalregpay,totaloverpay):

#Call to print total Gross Pay

    print('Total Regular Hours:',totalreghours)

    print('Total Overtime Hours:',totaloverhours)

    print('Total Regular Pay:',totalregpay)

    print('Total Overtime Pay:',totaloverpay)

main()

Explanation / Answer

reghours = 0
overtime = 0
payrate = 0.0
regpay = 0.0
overpay = 0.0
totalpay = 0.0
def main():
    totalreghours = 0
    totaloverhours = 0
    totalregpay = 0.0
    totaloverpay = 0.0
# Variable to control the loop.
    another = 'y'
# Process another employee.
    while another == 'y':
# Get employee info input
        name = input(' Enter Employees Last Name: ')
        payrate = float(input(' Enter Employees Pay Rate(Per Hour): $'))
        hours = int(input(' Enter Hours Worked: '))
        reghours, overtime = calc_hours(hours)
        regpay, overpay, totalpay = calc_pay(reghours,overtime,payrate)
# Summary of employee after information was entered
        print(' Mr/Mrs',name, 'has a gross pay of, $',format(totalpay, '.2f'))
# Asking user if they want to enter more employee info
        totalreghours = totalreghours+reghours
        totaloverhours = totaloverhours + overtime
        totalregpay = totalregpay + regpay
        totaloverpay = totaloverpay + overpay
        another = input('Do you want to enter another employees info? (Enter "y" for yes or "n" for no): ')
# Call to print totals
    else:
        totals(totalreghours,totaloverhours,totalregpay,totaloverpay)
def calc_hours(hours):
    if hours < 40:
        reghours = hours
        overtime = 0
    else:
        reghours = 40
        overtime = hours - 40
    return (reghours, overtime)
def calc_pay(reghours,overtime,payrate):
    regpay = reghours * payrate
    overpay = overtime * (payrate * 1.5)
    totalpay = regpay + overpay
    return (regpay, overpay, totalpay)
def totals(totalreghours,totaloverhours,totalregpay,totaloverpay):
#Call to print total Gross Pay
    print(' Total Regular Hours:',totalreghours)
    print(' Total Overtime Hours:',totaloverhours)
    print(' Total Regular Pay:',totalregpay)
    print(' Total Overtime Pay:',totaloverpay)
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote