Question: Program Specifications: For this problem, you will write a program to do some basic file processing. The goal of this is to carry out some
Program Specifications: For this problem, you will write a program to do some basic file processing. The goal of this is to carry out some banking transactions for the customers of a bank. Assume for our purposes that each customer has exactly one account at the bank. The bank maintains two files of data.
One file, called balance.dat, contains account balance information for each customer of the bank. Each line of this file contains three data items: A customers bank account number, the social security number SSN and the balance at the end of the previous business period this might a month, a week, or a day, but the actual length of the business period is not relevant for our purposes The bank account number is simply a three digit integer unique to each customer the SSN is a string of digits in the usual format xxxxxxxxx and the balance is a real value.
The second file, called transactions.dat, contains all the bank transactions that have taken place in the current business period for all the customers at the bank. Each line of this file contains just two data items: a bank account number and the dollar amount of the transaction. If the transaction is a deposit, it is indicated as a positive value and if it is a payment withdrawal it is indicated as a negative value. A customers bank account number may appear several times in the file if they had several transactions during the business period or may not appear at all if they did not carry out any transactions at the bank during the business period A transaction is simply recorded at the time that it takes place, hence the account numbers may appear in any order in the file and all the transactions for a particular account may not appear together that is on consecutive lines in the file.
The goal is to update each customers bank balance information by taking into account all transactions deposits as well as withdrawals that have taken place in the current business period. If the resulting account balance is greater than $ a interest on the new account balance is added on If the resulting account balance is less than $ a $ penalty is applied to the account.
The bank management has asked you to write a program to create two tables. One table, called the New Balance, contains the new account balance information the bank will eventually replace the balance. dat file with the information from this table Each row of this table should contain the customers bank account number, their SSN and the new balance at the end of the current business period. The second table, called Transaction Summary, should contain transaction summaries for all the customers of the bank. It should contain, for each customer, their account number, SSN the old balance, total of all deposits made, total of all withdrawals made, the interest amount added, the penalty added, and the final new balance.
You will carry out this task by implementing the following functions: Our implementation will make heavy use of dictionaries. In particular, you will work with dictionaries in which each key is a threedigit integer this will be the customers bank account number and the value associated with a key is a list. Further details are provided below.
A Implement a function called create cust dictionary with a single parameter balancefile, the name of the file containing the account balance information for each customer of the bank such as the file balance.dat described above This function should open balancefile for reading, and then read this file one line at a time to create a customer dictionary. This dictionary has the customer account number as the key. The value associated with each key is a list of four items: The first item is the customers SSN a string the second item is the customers current account balance a real value the third item is the total deposit into this customers account in the current business period set this to and the fourth item is the total withdrawal from this customers account in the current business period set this to This function returns this dictionary.
B Implement a function called update cust dictionary with two parameters: cdictionary a dictionary containing customer data in the format described above and transfile, the name of the file containing all the bank transaction information for the current business period such as the file transactions.dat described above This function should open transfile for reading, and then read this file one line at a time to update the customer dictionary cdictionary. Recall that this dictionary has the customer account number as the key. The function should update the appropriate items in the list associated with each key.
C Implement two function called processtransactionsnewbalance for preparing New Balance table and processtransactionstransectionsummary for Transection Summary table with two parameters: oldbalfile the name of the file containing account balance information for all customers transfile the name of the file containing all transactions
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
