-
Notifications
You must be signed in to change notification settings - Fork 0
/
computePay.py
41 lines (35 loc) · 1.43 KB
/
computePay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#EXERCISE1
#rewrite your pay computation with time-and-a-half for overtime and create a function called computepay which takes 2 parameter (hours and rate)
def computePay():
'''
The program take hours and rate, and calculate the ordinary payment and extra payment if apply.
Extraordinary payment applies only if hours per week exceed 40 hours, otherwise ordinary payment is applying.
The program does not recognize the numbers as string, please enter only numbers
>>>computePay(40,8)
>>>320.0
>>>ComputePay(45,10)
>>>475.0
'''
#http://www.overclock.net/t/342279/tutorial-using-python-glade-to-create-a-simple-gui-application#post3995587
#This is the page for the tutorial of the interface
extra_pay = 0
while True:
try:
hours = int(raw_input("Please enter a number for hours: \n"))
break
except ValueError:
print "Oops! That was no valid number. Please enter a valid value for hours..."
while True:
try:
rate = int(raw_input("Please enter a number for rate: \n"))
break
except ValueError:
print "Oops! That was no valid number. Please enter a valid value for rare..."
if hours <= 40:
ordinary_pay = 40 * rate
else:
ordinary_pay = 40 * rate
extra_pay = (hours - 40) * rate * 1.5
total_pay = ordinary_pay + extra_pay
return float(total_pay)
print computePay()