-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadvPayroll.py
More file actions
61 lines (56 loc) · 1.5 KB
/
advPayroll.py
File metadata and controls
61 lines (56 loc) · 1.5 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
61
'''
Enter hours: 12
Gross:
Tax:
Nett:
Another calculation? Y/N
[If N -> Write last value to a file (HTML)]
'''
hours = 0
otrate = 1.5
taxrate = 0.18
basic = 15
reghours = 40
gross,tax,nett = 0,0,0
quit = False
userInput = None
while(quit != True):
while True:
try:
hours = float(input("Enter hours worked:"))
if hours < 0:
raise ValueError
break
except:
print("Invalid entry. Must be a positive number")
if(hours > reghours):
gross = ((hours - reghours) * otrate * basic) + (reghours * basic)
else:
gross = hours * basic
tax = gross * taxrate
nett = gross - tax
print(f"Gross:\t\t {gross:7.2f}")
print(f"(-)Tax:\t\t {tax:7.2f}")
print(f"Nett:\t\t {nett:7.2f}")
print()
userInput = input("Another calculation? Y/N")
if (userInput == 'Y' or userInput == 'y'):
quit = False
elif (userInput == 'N' or userInput == 'n'):
quit = True
with open('result.html','w') as resultWriter:
resultStr = '''
<html>
<head>
</head>
<body>
<h1>Your Salary Info</h1>
<div>Gross: {0:.2f}</div>
<div>Gross: {1:.2f}</div>
<div>Gross: {2:.2f}</div>
</body>
</html>
'''.format(gross,tax,nett)
resultWriter.write(resultStr)
else:
print("Invalid entry. Resuming program")