Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2012, 07:53 PM
jwhit1984 jwhit1984 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 6 jwhit1984 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 59 m 3 sec
Reputation 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 09:44 PM. Reason: NO ANSWER

Reply With Quote
  #2  
Old October 24th, 2012, 09:48 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,359 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 9 h 43 m 13 sec
Reputation Power: 383
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()
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > I need help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap