Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- oDate = ''
- cPctr = 0
- dataFile = ''
- def main():
- iRec = init()
- while iRec != "":
- cStoreCost, iQty, iPrice = calcs(iRec)
- output(cStoreCost, iQty, iPrice, iRec)
- iRec = read()
- closing()
- def closing():
- print("\n")
- dataFile.close()
- def output(cStoreCost, iQty, iPrice, iRec):
- iStoreName = iRec[0:10]
- iPatch = iRec[11:12]
- if iPatch == 'N':
- oPatch = "North"
- elif iPatch == 'S':
- oPatch = "SkunkCreek"
- else:
- oPatch = "Back 40"
- print(iStoreName, format(" ", "7s"), oPatch, format(" ", "9s"), iQty,
- format(" ", "15s"), iPrice, format(" ", "6s"), cStoreCost)
- def calcs(iRec):
- iQty = int(iRec[12:15])
- iPrice = float(iRec[15:20])
- cStoreCost = (iQty * iPrice)
- return cStoreCost, iQty, iPrice
- def init():
- global oDate
- global dataFile
- dataFile = open(r'data/pumpkin.dat', 'r')
- oDate = datetime.datetime.today().strftime('%m/%d/%Y')
- headings()
- iRec = read()
- return iRec
- def read():
- iRec = dataFile.readline()
- return iRec
- def headings():
- global cPctr
- cPctr = cPctr + 1
- print("Date: ", oDate, format(" ", "15s"), "Pumpkin Patch Ranch", format(" ", "16s"), "Page: ", format(cPctr, "2d"))
- print(format(" ", "36s"), "Sales Report\n")
- print("Store Name", " ", "Patch Name", " ", "Quantity", " ",
- "Price", " ", "Store Cost\n")
- main()
Advertisement
Add Comment
Please, Sign In to add comment