[Solved]Python Programming Asked Question Multiple Times One Willing Help Requirements Program Pr Q37109756
Python Programming: I asked this question multiple times and noone has been willing to help me.
Requirements:
-
- Your program will process the individual transactions againstcustomer accounts (in case you weren’t sure…there are multiplecustomers, but they only have one account each).
- Your program should ask for the path to the files containingthe customer and transaction data. The instructor will use testfiles that will not be made available to the student.
- You will produce an updated customer master file that containsthe new beginning balance, which will be the end balance after youare finished processing all transactions.
- Beginning Balance
- Less Checks
- Plus Deposits
- Plus Interest earned
- Ending Balance – This will become the new value ofthe beginning balance.
- The interest paid is .25% of the ending balance. Bonus forcomputing it as average daily balance in theaccount (note the bolded text).
- At the end of the run produce an error reportfile that contains all of the errant transactions found duringprocessing. This output should contain information to identify thetransaction and a list of the problems found with the item.DUPLICATED CHECK NUMBERS AND BOGUS ACCOUNT NUMBERS AREDEFINITE ERRORS!!
- This program should be built to handle millions oftransactions, so use algorithms that are maximized for largenumbers of transactions (i.e. shell sorts).
- You will be graded based on successful completion of theassignment, correctness of output, and quality of your codingpractice (naming, comments, proper
- use of structure, coupling, cohesion, etc.)
CurTrans File
4571-2546-13671,10/03/2017,24000.5,1002
4571-2546-13671,10/22/2017,36.59,1003
4571-2546-13671,10/30/2017,500,DEP
4571-2546-13672,10/03/2017,4000,1790
4571-2546-13672,10/06/2017,45,1791
4571-2546-13672,10/10/2017,1006,1792
4571-2546-13672,10/10/2017,34.58,DEP
4571-2546-13672,10/10/2017,91.26,DEP
4571-2546-13672,10/22/2017,25,1793
4571-2546-13672,10/30/2017,650.98,DEP
4571-2546-13684,10/03/2017,50,1112
4571-2546-13684,10/03/2017,4500,1117
4571-2546-13684,10/04/2017,130,1118
4571-2546-13684,10/07/2017,50,1119
4571-2546-13684,10/11/2017,46.89,1114
4571-2546-13684,10/11/2017,13.59,DEP
4571-2546-13684,10/11/2017,34.79,DEP
4571-2546-13684,10/13/2017,26.78,1115
4571-2546-13684,10/21/2017,31.45,1116
4571-2546-13684,10/31/2017,13.59,1117
4576-2546-46719,10/11/2017,45,601
4576-2546-46719,10/21/2017,10,602
4576-2546-46798,10/03/2017,130,DEP
4576-2546-46798,10/07/2017,91.26,603
4576-2546-46798,10/13/2017,21,604
4590-2546-13135,10/22/2017,450,606
4598-2546-86971,10/03/2017,50,1356
4598-2546-86971,10/03/2017,4250,1357
4598-2546-86971,10/03/2017,30,1358
4598-2546-86971,10/03/2017,20,1359
4598-2546-86971,10/04/2017,20,1359
4598-2546-86971,10/10/2017,64.89,1360
4598-2546-86971,10/11/2017,45.26,1361
4598-2546-86971,10/13/2017,2648.36,DEP
4598-2546-86971,10/15/2017,450,DEP
4598-2546-86971,10/15/2017,130.6,1362
4598-2546-86971,10/15/2017,50,1363
4598-2546-86971,10/15/2017,500,DEP
4598-2546-86971,10/27/2017,3000,DEP
4598-2546-86972,10/03/2017,750,1578
4598-2546-86972,10/07/2017,34.79,1579
4598-2546-86972,10/07/2017,1006,DEP
4598-2546-86972,10/10/2017,456.5,1580
4598-2546-86972,10/27/2017,19.95,1582
4599-2348-98456,10/21/2017,130.6,1583
4599-2546-97451,10/03/2017,10,1584
4599-2546-97451,10/04/2017,2648.36,DEP
4599-2546-97451,10/31/2017,46.89,1587
4599-2546-97452,10/03/2017,20,1588
4599-2546-97452,10/04/2017,26.78,1589
4599-2546-97452,10/04/2017,50,1590
4599-2546-97452,10/04/2017,79.56,1591
4599-2546-97452,10/21/2017,450,1592
4599-2546-97452,10/22/2017,35,1593
4599-2546-97452,10/27/2017,34.58,1594
4599-2546-98456,10/03/2017,2500,101
4599-2546-98456,10/04/2017,31.45,102
4599-2546-98456,10/04/2017,21,103
4599-2546-98456,10/04/2017,19.95,104
4599-2546-98456,10/04/2017,3000,DEP
4599-2546-98456,10/06/2017,79.56,105
4599-2546-98456,10/13/2017,35,106
4599-2546-98456,10/15/2017,46.89,107
4599-2546-98456,10/15/2017,20,108
4599-2546-98456,10/15/2017,79.56,109
4599-2546-98456,10/15/2017,91.26,110
4599-2546-98456,10/15/2017,36.59,111
4599-2546-98456,10/20/2017,30,112
4599-2546-98456,10/21/2017,20,113
4599-2546-98456,10/21/2017,50,114
4599-2546-98456,10/22/2017,64.89,115
4599-2546-98456,10/27/2017,650.98,DEP
4599-2546-98456,10/28/2017,45.26,116
4599-2546-98456,10/29/2017,10,119
4599-2546-98456,10/29/2017,50,120
CustFile
4598-2546-86971,Lipps,Bugger,24 Hunterwasser,,EllensBurg,VA,05621-0123,650.45
4571-2546-13671,Munster,Herman,1313 Mockingbird Lane, ,LosAngeles,CA,95621-6089,35000.15
4571-2546-13672,Munster,Lilly,1313 Mockingbird Lane, ,LosAngeles,CA,95621-6089,450.55
4599-2546-97451,Chong,Yon,325 Faircrest Dr.,AptD,Arlington,TX,76018-6033,0
4599-2546-98456,Husein,Ahmed,2424 Second St.,Apt 123,Ft.Worth,TX,76180-4040,5000
4576-2546-46798,Tang,Pu Din,45 Lovers Ln., ,GrandPrarie,TX,75148-1533,50.87
4598-2546-86972,Hummer,Cindy,48 Hunterwasser, ,BigBug,VA,06022-9033,750.55
4571-2546-13684,Munson,Hellen,4568 Mockingbird Lane,Apt. 99,LosAngeles,CA,96218-7032,350.35
4571-2546-13459,Majors,Lilly,1313 Munchousen,,Seatle,WA,89213-0000,9000.97
4599-2546-97452,Chul,Pun C.,985 Faircrest Dr.,AptD,Arlington,TX,76018-6033,500.35
4999-2546-98413,Huttin,Anne,45 Second St.,Apt198,Stevenville,TX,73210-1283,4500.25
This is the program I have and I can’t seem to figure itout:
# Declarations
masterfile_in = ”
transfile_in = ”
updatedfile_out = ”
masterRecord = []
transRecord = []
# Constants and Switches – Kill both of these.
# END_NUM = 9999 # Very old and limiting way to do this… so let’sKILL it.
# areBothAtEnd = False # Going to use a Boolean, because I can andit’s easier to read
# Modern Problems Require Modern Solutions
# IMROVED RECORD COMPARISON ITEMS
current_mstr = str()
current_trans = str()
eof_mstr = False
eof_trans = False
balance = ‘999999’
interest = 0.25
trans_count = 0
trans_total = 0
def readMaster():
“””
This function reads the next record from the Master file. Alsochecks to see if at the end of the file.
This function will load a record, and then set values forcomparison and accumulation.
:return: *Really just sets the module level variables indicatingthe end.
“””
global masterRecord
# Improved method
global eof_mstr
global current_mstr
masterRecord =masterfile_in.readline().rstrip(‘n’).split(‘,’)
if masterRecord[0] == ”:
# Reading into a list will always produce at least one element, so[0] is OK.
# masterRecord[0] = END_NUM #kill this weird method
eof_mstr = True
else:
# Set a standard current record value. This eleminates issue ofvalues being in various element locations.
current_mstr = masterRecord[0]
def readTrans():
“””
This function reads the next record from the Transaction file. Alsochecks to see if at the end of the file.
This function will load a record, and then set values forcomparison and accumulation.
:return: *Really ust sets the module level variables indicating theend.
“””
global transRecord
global trans_count
global trans_total
# Improved method
global eof_trans
global current_trans
transRecord = transfile_in.readline().rstrip(‘n’).split(‘,’)
if transRecord[0] == ”:
# Reading into a list will always produce at least one element, so[0] is OK.
# transRecord[0] = END_NUM # kill this old timie method
eof_trans = True
else:
# Set a standard current record value. This eleminates issue ofvalues being in various element locations.
# Do all the detail work here so rest of program doesn’t know thedifference
current_trans = transRecord[3]
def houseKeeping():
“””
This function performs the initial set up for the processingoperation. File handles are opened.
:return:
“””
global masterfile_in
global transfile_in
global updatedfile_out
masterfile_in = open(‘CustFile.txt’, ‘r’)
transfile_in = open(‘CurTrans.txt’, ‘r’)
updatedfile_out = open(‘ScottJrUPDAMSTR.txt’, ‘w’)
def updateRecords():
“””
This is the central transform operation of the program. We processthe transactions against
the master records and calculate a new balance.
:return:
“””
# Remember that if we aren’t chnaging a module level variable, wedon’t need to list it as global here.
# We need to control our loop inside this function. Also means wecan do our lead reads here as well
global trans_count
global trans_total
global balance
global new_balance
readMaster()
readTrans()
while (eof_mstr == False) and (eof_trans == False):
# Using a standard comparison variable… so no out of rangeissue
if current_mstr == current_trans:
# Process this transaction record and get next trans
# Now that we have a better understanding of lists, let’s use thatpower. Ask me in class why
# we can accumulate right to the list element itself.
if transRecord[3] == ‘DEP’:
trans_count = trans_count + 1
trans_total = trans_total + float(transRecord[1])
# Get next Transaction
readTrans()
else:
if current_mstr < current_trans:
# We are into the next customers transactions
writeUpdate()
trans_count = 0
trans_total = 0
# Get the next Master
readMaster()
else:
# We would normally output this to an error file…but you canfigure that out for yourself
errorOutput()
readTrans()
# We’re done, so write out the last customer’s data
writeUpdate()
# If we have more master records, we can just write them to theupdated master file. If we have left over transactions
# at this point…they’re all bad and I call shennanigans.
def writeUpdate():
“””
This function handles writing the updated customer record tofile.
:return:
“””
outputRec = str(masterRecord[0]) + ” + str(masterRecord[1]) + ‘n’+ str(trans_total) + ‘n’ + str(trans_count) + ‘n’ + str(balance)+ ‘n’ + str(new_balance) + ‘n’
updatedfile_out.write(outputRec)
def errorOutput():
errorfile_out = open(‘ScottJrERR.txt’, ‘w’)
outputRec = str(masterRecord[0]) + ‘,’ + str(masterRecord[1]) + ‘,’+ ‘This is a bad transaction’
errorfile_out.write(outputRec)
def finishUp():
“””
Wraps up processing and closes all open resources.
:return:
“””
masterfile_in.close()
transfile_in.close()
updatedfile_out.close()
def Main():
“””
Mainline logic for this program
:return:
“””
houseKeeping()
updateRecords()
finishUp()
if __name__ == ‘__main__’:
Main()
Expert Answer
Answer to Python Programming: I asked this question multiple times and no one has been willing to help me. Requirements: Your prog… . . .
OR

