Good evening everyone,
I am once again posting a question. My school project is done. And I appreciate all the help you gave me. The following code is a working program. The only thing I have absolutely no real good idea to do is calculate the Overtime Rate with my variables. I can't seen to find out. Here is my code:

#ASCII Images and Text
raw_input("""

 _______  __  .__   __.      ___       __      
|   ____||  | |  \ |  |     /   \     |  |     
|  |__   |  | |   \|  |    /  ^  \    |  |     
|   __|  |  | |  . `  |   /  /_\  \   |  |     
|  |     |  | |  |\   |  /  _____  \  |  `----.
|__|     |__| |__| \__| /__/     \__\ |_______|
                                               
.______   .______        ______          __   _______   ______ .___________.
|   _  \  |   _  \      /  __  \        |  | |   ____| /      ||           |
|  |_)  | |  |_)  |    |  |  |  |       |  | |  |__   |  ,----'`---|  |----`
|   ___/  |      /     |  |  |  | .--.  |  | |   __|  |  |         |  |     
|  |      |  |\  \----.|  `--'  | |  `--'  | |  |____ |  `----.    |  |     
| _|      | _| `._____| \______/   \______/  |_______| \______|    |__|     
 	                                           
 	                                       
 	                                        

             ,----------------,              ,---------,
        ,-----------------------,          ,"        ,"|
      ,"                      ,"|        ,"        ,"  |
     +-----------------------+  |      ,"        ,"    |
     |  .-----------------.  |  |     +---------+      |
     |  |                 |  |  |     | -==----'|      |
     |  | I Love Python!  |  |  |     |         |      |
     |  | And you can TOO!|  |  |/----|`---=    |      |
     |  |                 |  |  |   ,/|==== ooo |      ;
     |  |                 |  |  |  // |(((( [33]|    ,"
     |  `-----------------'  |," .;'| |((((     |  ,"
     +-----------------------+  ;;  | |         |,"
        /_)______________(_/  //'   | +---------+
   ___________________________/___  `,
  /  oooooooooooooooo  .o.  oooo /,   \,"-----------
 / ==ooooooooooooooo==.o.  ooo= //   ,`\--{)B     ,"
/_==__==========__==_ooo__ooo=_/'   /___________,"
`-----------------------------'
____,"
`-----------------------------'


 """)

#Starts Program
raw_input("\nHit ENTER to start Payroll Program.")

#Mainline
hours=[]
hWork="1"

#Intial Loop
while True:
    eName=raw_input("\nPlease enter the employees' first and last name. ")
    hWork=raw_input("How many hours did they work this week? ")
    intWork=int(hWork)
#Condition 1
    if intWork < 1 or intWork > 60:
        print "Employees' can't work more than 60 hours or less than 1 hour!"
        continue
#Condition 2
    else:
        pRate=raw_input("What is their hourly rate? ")
        intRate=int(pRate)
#Condition 3
        if intRate < 6 or intRate > 20:
            print "Employees' wages can't be  or greater than $20.00 lower than $6.00!"
#Condition 4
        else:
            Salary=intWork*intRate
            strmoney=str(Salary)
            hours.append(strmoney + "\n")
            ePass = ""
            ePass = raw_input("Type DONE when finished with employees' information. ")
            if ePass  == "DONE":
                
#I/O Exceptions
                try:
                    hoursFile=open("PAY.txt", "w")
                    hoursFile.writelines(hours)
                    hoursFile.close()
                except(IOError):
                    print "Error writing hours! "
                    quit()
                try:
                    hoursFile=open("PAY.txt", "r")
                    hoursList=hoursFile.readlines()
                    hoursFile.close()
                    hoursList.sort()
                except(IOError):
                    print "Error writing names! "
                    quit()
                break


#Mainline 1
def employee():
    global Name
    global Rate
    global Work

#Mainline 2
def Lowest(hours):
    hours.sort()
    lowestPay = hours[0]
    return lowestPay

#Mainline 3
def Highest(hours):
    hours.sort()
    highestPay=hours[len(hours)-1]
    return highestPay

#Mainline 4
def Average(hours):
    total=0
    for hour in hours:
        total += int(hour)
    avgPay = total / len(hours)
    return avgPay

#Prints Salary Totals
print Lowest(hours)
print Highest(hours)
print Average(hours)

I would appreciate any feedback you guys can give me. Like I said I am not quite sure how to calculate overtime with my variables (to be honest I don't really know much about Python). Thank you so very much for your feedback. This is a great site. And I will continue to use this site in the future when it comes to trouble shooting.

Recommended Answers

All 2 Replies

I notice that your condition 3 is missing a continue statement...

To answer your question however, you should check to see if intWork is greater than 40 and if it is, calculate the overtime based on the number of hours over 40 that the employee worked.

When someone enters pay rate or hours, what happens if they accidentally enter a letter or a float instead (pay rate is $9.99)? Or does the problem let you assume that only integers are entered,

pRate=raw_input("What is their hourly rate? ")
intRate=int(pRate)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.