-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
87 lines (72 loc) · 2.68 KB
/
main.py
File metadata and controls
87 lines (72 loc) · 2.68 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
item = []
itemPrice = []
itemUnit = []
itemAmount = []
itemlist = 0
price = []
itemx = 0
itemy = 0
with open("item.txt", "r") as item:
item = item.readlines()
item = [i.replace('\n','') for i in item]
with open("itemPrice.txt", "r") as itemPrice:
itemPrice = itemPrice.readlines()
itemPrice = [i.replace('\n','') for i in itemPrice]
with open("itemUnit.txt", "r") as itemUnit:
itemUnit = itemUnit.readlines()
itemUnit = [i.replace('\n','') for i in itemUnit]
with open("itemAmount.txt", "r") as itemAmount:
itemAmount = itemAmount.readlines()
itemAmount = [i.replace('\n','') for i in itemAmount]
def CalPrice():
global itemlist
global price
itemx = itemPrice[itemlist]
itemy = itemAmount[itemlist]
itemx = float(itemx)
itemy = float(itemy)
price.append(itemx * itemy)
def PrintReceipt():
CalPrice()
global itemlist
global price
out = f"{item[itemlist]} {itemUnit[itemlist]} {itemPrice[itemlist]} | {itemAmount[itemlist]} | {price[itemlist]}"
print(out)
out = f"{item[itemlist]} {itemUnit[itemlist]} {itemPrice[itemlist]} | {itemAmount[itemlist]} | {price[itemlist]}\n"
f.write(out)
print("Store info:".center(53))
print("name: SweetyMart".center(53))
print("address: 123321 Funny St, Farmland, V0V 4N4".center(53))
print("tel:604-555-1234".center(53))
print("website: www.sweetymark.ca".center(53))
print("".center(53))
print("".center(53))
print("Cashier ID: goody-mark".center(53))
print("Date time also should be on the receipt".center(53))
print("".center(53))
print("*****************************************************")
print("Item | Unit | Price | Amount | Total")
with open('Receipt.txt', 'w') as f:
f.write("Store info:".center(53) + "\n")
f.write("name: SweetyMart".center(53) + "\n")
f.write("address: 123321 Funny St, Farmland, V0V 4N4".center(53) + "\n")
f.write("tel:604-555-1234".center(53) + "\n")
f.write("website: www.sweetymark.ca".center(53) + "\n")
f.write("".center(53) + "\n")
f.write("".center(53) + "\n")
f.write("Cashier ID: goody-mark".center(53) + "\n")
f.write("Date time also should be on the receipt".center(53) + "\n")
f.write("".center(53) + "\n")
f.write('*****************************************************\n')
f.write('Item | Unit | Price | Amount | Total\n')
while not itemlist == 6:
itemx = float(itemPrice[itemlist])
itemy = float(itemPrice[itemlist])
PrintReceipt()
itemlist = itemlist +1
f.write("*****************************************************\n")
total = sum(price)
f.write(f" {total}\n")
print("*****************************************************")
total = sum(price)
print(" ", total)