We also have to include some basic validation to ensure the user enters an amount of hours, or pay, within a given range.
There's more to the program than that... but that's just where I am right now.
I typed this up rather quickly, but it is somewhat doing what I want.
while True:
employeeName = raw_input("Please enter the employee's first and last name: \n")
if len(employeeName) == 0:
print "You entered nothing.\n"
continue
else:
workedHours = int(raw_input("How many hours did the employee work?\n"))
if workedHours < 1:
print "Employees can't work less than 1 hour per week. Please try again."
continue
elif workedHours > 60:
print "Employees can't work more than 60 hours per week. Please try again."
continue
else:
payRate = float(raw_input("What is the employee's hourly wage?\n"))
if payRate < 6.00:
print "Employee must earn no less than $6.00 an hour. Please try again."
continue
elif payRate > 22.00:
print "Employee must earn no more than $22.00 an hour. Please try again."
continue
What it does do:Does ask for an employee name.
Does ask for hours worked, and makes sure they're within range.
Does ask for hourly wage, and makes sure it's within the correct range.
However, as it is right now, if the wrong info is entered it just starts back asking the employee name. I'd like to re-ask for whatever was out of range instead.
I guess I'm looking more for pointers and some tips, and not someone to recode this for me.
Thanks!


Sign In
Create Account



Back to top









