-
Notifications
You must be signed in to change notification settings - Fork 0
/
Return.py
55 lines (45 loc) · 1.79 KB
/
Return.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import ListSplit
import dt
def returnBook():
name=input("Enter name of borrower: ")
a="Borrow-"+name+".txt"
try:
with open(a,"r") as f:
lines=f.readlines()
lines=[a.strip("$") for a in lines]
with open(a,"r") as f:
data=f.read()
print(data)
except:
print("The borrower name is incorrect")
returnBook()
b="Return-"+name+".txt"
with open(b,"w+")as f:
f.write(" Library Management System \n")
f.write(" Returned By: "+ name+"\n")
f.write(" Date: " + dt.getDate()+" Time:"+ dt.getTime()+"\n\n")
f.write("S.N.\t\tBookname\t\tCost\n")
total=0.0
for i in range(3):
if ListSplit.bookname[i] in data:
with open(b,"a") as f:
f.write(str(i+1)+"\t\t"+ListSplit.bookname[i]+"\t\t$"+ListSplit.cost[i]+"\n")
ListSplit.quantity[i]=int(ListSplit.quantity[i])+1
total+=float(ListSplit.cost[i])
print("\t\t\t\t\t\t\t"+"$"+str(total))
print("Is the book return date expired?")
print("Press Y for Yes and N for No")
stat=input()
if(stat.upper()=="Y"):
print("By how many days was the book returned late?")
day=int(input())
fine=2*day
with open(b,"a")as f:
f.write("\t\t\t\t\tFine: $"+ str(fine)+"\n")
total=total+fine
print("Final Total: "+ "$"+str(total))
with open(b,"a")as f:
f.write("\t\t\t\t\tTotal: $"+ str(total))
with open("Stock.txt","w+") as f:
for i in range(3):
f.write(ListSplit.bookname[i]+","+ListSplit.authorname[i]+","+str(ListSplit.quantity[i])+","+"$"+ListSplit.cost[i]+"\n")