1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Oct 2012
Posts
6
Rep Power
0

#### ****Need Help Asap****

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 – at the end of the program you will need to display the total payroll amounts.

Requirements:

1) Must contain a main function – 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’d like to enter more or quit

….

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

(… this is just an example….)

Total Regular Hours: 765

Total Overtime Hours: 65

Total Regular Pay \$76,001.50

Total Overtime Pay \$560.71

This is what i have so far
# Global constants
BASE_HOURS = 40 # Base hours per week
OT_MULTIPLIER = 1.5 # Overtime multiplier

# The main function gets the number of hours worked and
# the hourly pay rate. It calls either the calc_pay_with_OT
# function or the calc_regular_pay function to calculate
# and display the gross pay.
def main():
# Create a variable to control the loop
keep_going = 'y'
while keep_going == 'y':

# Get name the hours worked and the hourly pay rate.
last_name = input('Enter employees name: ')
hours_worked = float(input('Enter the number of hours worked: '))
pay_rate = float(input('Enter the hourly pay rate: '))

# Calculate and display the gross pay.
if hours_worked > BASE_HOURS:
calc_pay_with_OT(hours_worked, pay_rate)
else:
calc_regular_pay(hours_worked, pay_rate)

# The calc_pay_with_OT function calculates pay with
# overtime. It accepts the hours worked and the hourly
# pay rate as arguments. The gross pay is displayed.
def calc_pay_with_OT(hours, rate):
# Calculate the number of overtime hours worked.
overtime_hours = hours - BASE_HOURS

#Calculate the amount of overtime pay.
overtime_pay = overtime_hours * rate * OT_MULTIPLIER

# Calculate the gross pay.
gross_pay = BASE_HOURS * rate + overtime_pay

# Display the gross pay.
print('The gross pay is \$', format(gross_pay, ',.2f'), sep='')

# The calc_regular_pay function calculates pay with
# no overtime. It accepts the hours worked and the hourly
# pay rate as arguments. The gross pay is displayed.
def calc_regular_pay(hours, rate):
# Calculate the gross pay.
gross_pay = hours * rate

# Display the gross pay.
print('The gross pay is \$', format(gross_pay, ',.2f'), sep='')

# Call the main function.
main()
Last edited by jwhit1984; October 24th, 2012 at 10:44 PM. Reason: NO ANSWER
2. Code:
```# an untested program in python3 intended to conform with the instructions somewhat more than did the original

# Global constants
BASE_HOURS = 40 # Base hours per week
OT_MULTIPLIER = 1.5 # Overtime multiplier

# compute and return overtime pay
def calc_pay_with_OT(hours, rate):
# Calculate the number of overtime hours worked.
overtime_hours = max(0, hours - BASE_HOURS) # implicit "if" statement here
overtime_pay = overtime_hours * rate * OT_MULTIPLIER
return overtime_pay

# compute and return regular time pay
def calc_regular_pay(hours, rate):
regular_hours = min(hours, BASE_HOURS) # implicit "if" statement here
regular_pay = regular_hours*rate
return regular_pay

# The main function gets the number of hours worked and
# the hourly pay rate. It calls either the calc_pay_with_OT
# function or the calc_regular_pay function to calculate
# and display the gross pay.
def main():
# Create a variable to control the loop
keep_going = 'y'
total_overtime_pay = total_regular_pay = 0
while keep_going == 'y':
# Get name the hours worked and the hourly pay rate.
last_name = input('Enter employees name: ')
hours_worked = float(input('Enter the number of hours worked: '))
pay_rate = float(input('Enter the hourly pay rate: '))

# Calculate and display the gross pay.
regular_pay = calc_regular_pay(hours_worked,pay_rate)
overtime_pay = calc_pay_with_OT(hours_worked,pay_rate)

total_regular_pay += regular_pay
total_overtime_pay += overtime_pay

gross_pay = regular_pay + overtime_pay

# Display the gross pay.
print('The gross pay is \$', format(gross_pay, ',.2f'), sep='')

keep_going = input('enter y to continue')

print('total regular pay is',total_regular_pay

# Call the main function.
main()```