-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypayroll.py
More file actions
60 lines (50 loc) · 1.45 KB
/
mypayroll.py
File metadata and controls
60 lines (50 loc) · 1.45 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name = ""
payrate = 9.75
hoursworked = 0
federaltax = 0.20
statetax = 0.09
grosspay = 0
netpay = 0
def set_employee():
global name, hoursworked
name = input("What's your name? ")
hoursworked = float(input("How much did you work? "))
def hourlypay():
global hoursworked, payrate
if hoursworked < 0:
print(" something went wrong")
else:
amount = hoursworked * payrate
print("Pay is: $" + str(amount))
return amount
def federaltaxdeduction():
global federaltax, grosspay
tax = grosspay * federaltax
print("Federal tax deduction: $" + str(tax))
return tax
def statetaxdeduction():
global statetax, grosspay
tax = grosspay * statetax
print("State tax deduction: $" + str(tax))
return tax
def calculatepay():
global grosspay, hoursworked, payrate
grosspay = hoursworked * payrate
print("Gross pay is: $" + str(grosspay))
return grosspay
def netpay():
global netpay, grosspay
taxfederal = federaltaxdeduction()
taxstate = statetaxdeduction()
netpay = grosspay - (taxfederal + taxstate)
print("Net pay is $" + str(netpay))
return netpay
def main():
set_employee()
calculatepay()
netpay()
choice = input("Do you want to continue? (yes/no) ").lower()
if choice != "yes":
print("Ok bye!")
break
main() __name__ == "__main__"