Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python - Bank Transaction The goal is to update each customers bank balance information by taking into account all transactions (deposits as well as withdrawals)

Python - Bank Transaction 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 $3000, a 2% interest (on the new account balance) is added on. If the resulting account balance is less than $100, a $10 penalty is applied to the account. Your program must create two files. One file 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. The second file is the file containing the new account balance information (the bank will eventually replace the old account balance file with this one). Each line of this file should contain the customers SSN, bank account number, and the new balance at the end of the current business period. All of the data in the output files should be formatted nicely. In particular, the bank account number and SSN should be printed left-justified in appropriately chosen field widths. All dollar amounts should be printed right-justified, with a precision of 2, in appropriately chosen field widths. For the purposes of formatting, you may assume that bank balances are always below $100,000. The columns in the output file should be given appropriate headings as well (see sample files below). The above task will be accomplished by using a dictionary to keep track of a customers transactions for the current business period, as specified in the following three functions:

1. Implement a function called customer dictionary with a single parameter balfilename, the name of the file containing current account balance information for the customers of the bank in the format described above The function should open balfilename for reading. It should then create a dictionary with key:value pairs in which the key is the bank account number of a customer, and the value associated with a key is a list containing the SSN and the account balance for that customer. The function must return the dictionary. Remember to close the file prior to the return statement. 2. Implement a function called update customer dictionary with two parameters. The first parameter, cdictionary, is the customer dictionary described above. The second parameter, transfilename, is the name of the file containing all the transactions for all the customers at the bank in the format described above This function should open transfilename for reading, and then update the cdictionary to include all the deposits 3 and withdrawals for each customer. Recall that the value associated with each customer is a list. Hence, the deposits and the withdrawals for a customer can be recorded as additional entries in the list. Remember to close the file after it has been read completely. 3. Implement a function called new balance files to create the two output files described above. This function has three parameters: The first parameter, cdictionary, is the customer dictionary described above. The second parameter, summfilename, is the name of the file containing the transaction summaries for the customers of the bank. The third parameter, newbalfilename, is the name of the file containing the new account balance information for all the customers. As noted above, the output files created by this function should be neatly formatted.

image text in transcribed

# INSERT ALL FUNCTION IMPLEMENTATIONS HERE # Document all functions if __name__ == "__main__": print("Running the problem1 module (Bank Transactions problem)") cdict = customer_dictionary("balance.dat") update_customer_dictionary(cdict, "transactions.dat") new_balance_files(cdict, "transsummary.dat", "newbalance.dat") print("Updated bank balance data appears in the files transsummary.dat and newbalance.dat") print("Goodbye!") 

Sample data:

https://ide.geeksforgeeks.org/F4j2WN6nQ9 
https://ide.geeksforgeeks.org/iqGwvwF2yk 

Thanks

 
An example is provided below. Consider the following example of the file containing account balance information: 123-45-6789 345-23-1782 672-39-1929 819-00-7810 100 300 700 900 348.17 3029.25 1800.87 -50.25 Suppose the file containing transactions data is the following file 900 150.25 100 525.72 100 -150.75 300 -500.00 100 -27.38 300-550.00 900 -120.00 300 2400.00 300 -300.00 Then the output file containing transaction summaries should look like this ACCOUNT# SSN PREV BAL DEPOSITS WITHDRAWALS INTEREST PENALTY NEW BAL 100 300 700 900 123-45-6789 345-23-1782 672-39-1929 819-00-7810 178.13 1350.00 0.00 120.00 0.00 81.58 0.00 348.17 525.72 3029.25 2400.00 0.00 150.25 0.00 695.76 0.00 4160.83 0.00 1800.97 0.00 10.00 -30.00 1800.87 -50.25 The output file containing the new account balance information should look like this: 123-45-6789 345-23-1782 672-39-1929 819-00-7810 100 300 700 900 695.76 4160.83 1800.97 -30.0 An example is provided below. Consider the following example of the file containing account balance information: 123-45-6789 345-23-1782 672-39-1929 819-00-7810 100 300 700 900 348.17 3029.25 1800.87 -50.25 Suppose the file containing transactions data is the following file 900 150.25 100 525.72 100 -150.75 300 -500.00 100 -27.38 300-550.00 900 -120.00 300 2400.00 300 -300.00 Then the output file containing transaction summaries should look like this ACCOUNT# SSN PREV BAL DEPOSITS WITHDRAWALS INTEREST PENALTY NEW BAL 100 300 700 900 123-45-6789 345-23-1782 672-39-1929 819-00-7810 178.13 1350.00 0.00 120.00 0.00 81.58 0.00 348.17 525.72 3029.25 2400.00 0.00 150.25 0.00 695.76 0.00 4160.83 0.00 1800.97 0.00 10.00 -30.00 1800.87 -50.25 The output file containing the new account balance information should look like this: 123-45-6789 345-23-1782 672-39-1929 819-00-7810 100 300 700 900 695.76 4160.83 1800.97 -30.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions