# Lee Her # CIS 122 # Ch.7 Program Ex 1: Payroll Program with Input Validation. # Last modified on 04/8/2015 #Get hourly wage wage = float(input("Please enter wage between.")) print while wage < 7.50 or wage > 18.50: wage = float(input("\n${} is Invalid, Please enter wage between $7.50 and $18.50.".format(wage))) print if wage > 7.50 or wage < 18.50: print "\nYour wage is ${}".format(wage) #Get hours worked hourWorked = int(input("\nPlease enter the amount of hours worked.")) print while hourWorked < 0 or hourWorked > 40: hourWorked = int(input("\n{} hours is Invalid, Please enter the amount of hours worked.".format(hourWorked))) print if hourWorked > 0 or hourWorked < 40: print "\nTotal hours worked: {}".format(hourWorked) #Calculate gross pay grossPay = wage * hourWorked print "\nYour weekly gross pay: ${}".format(grossPay) #END
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question