File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ '''Write a program to prompt the user for hours and rate per hour input to compute gross pay.
2+ Pay should be the normal rate upto 40 hours and time-and-a-half for the hourly rate for all hours worked above 40 hours
3+ Use function.'''
4+
5+ #definr function computepay that will calculate the gross pay
6+ def computepay (h ,r ):
7+ if h > 40 :
8+ pay = (40 * r )+ ((h - 40.0 )* r * 1.5 )
9+ else :
10+ pay = h * r
11+
12+ return pay
13+
14+ #take inputs
15+ hrs = input ('Enter hours: ' )
16+ rate = input ('Enter hourly pay: ' )
17+
18+ #chck if the inputs are correct
19+ try :
20+ vhrs = float (hrs )
21+ vrate = float (rate )
22+ except :
23+ print ('Hour and Rate must be numeric values.' )
24+ quit ()
25+
26+ #return gross pay
27+ gross = computepay (vhrs ,vrate )
28+ print (gross )
You can’t perform that action at this time.
0 commit comments