Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need This code in Python : Assume you are required to develop a banking system that tracks customers' records. You should be aware of

I need This code in Python :

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Assume you are required to develop a banking system that tracks customers' records. You should be aware of the following features in banking systems: 1- When a new account is opened, its initial balance is zero. 2- The withdraw operation will decrease the balance. Only withdraw is accomplished if the balance is enough (the balance is equal or greater than the amount to be withdrawn). 3- The deposit operation will increase the balance. 4- Close an account means inactivate it, no deposit or withdraw operation can be done with closed accounts. 5- To close an account, its balance should be zero. The required system will keep track of the account's data and the transactions. 1- Account data: Every account has an account number, name, status, and balance. This data will be saved in a file called "customers.txt", where this data is separated by comma. "customers.txt - Notepad File Edit format View Help 123, Ahmed Rashed, a, 1000.0 456, Noof Khaled, c, 0.0 777, Ali Mahmodd, a, 4500.0 To save space, the account status will be represented as one letter: ' a ' for active, and ' c ' for closed. 2- Transaction data: Transaction data (withdraw and deposit) will be save in a file called "transactions.txt". Every transaction is added to the file as a single line that contains: account number, transaction type ('d' for deposit, and ' w ' for withdraw), and the amount as follows: Note for implementation: - To make your program more efficient and instead of accessing the files every time, you should upload the data at the beginning to a dictionary. Write a function to (or make it in the main) to read the data from file "customers.txt" and save it to a dictionary, where the key is the account number and the rest as value in a list as follows: \{123: ['Ahmed Rashed', 'a', '1000.0'], 456: ['Noof Khaled', 'c', '0.0'], 777: ['Ali Mahmood', 'a', '4500.0']\} Then all the operations in the system will be done on the data in the dictionary, like open account, close an account, ...etc. - Each function in the program will receive that dictionary to process the data. Only the transactions (withdraw, deposit) data that will be append to the file "transactions.txt". When user exists the system (option 8), your system should write the data of the dictionary to the file "customers.txt" in mode ' w ', so it is updated. Your program should interact with the user through the following: 1-Main Menu When your program starts, it should display the following menu Please select one of the following: 1- Open an account 2- Close an account 3- Withdraw 4- Deposit 5 - Inquiry 6- Transactions 7- Top five accounts 8- Exit Your choice: This menu will be repeated until use enters 8. 2- Option 1: When the user selects 1 , the system asks for account's data as follows: Your choice:1 Enter account number888 Enter customer name:Mansor Abdullah The input data will be added to the dictionary, where the default status is ' a ' and the initial balance is zero. In this option, when the user enters account number, the system should ensure there is no account already in the system with that ID. Option 2: When the user select 2, the system asks for account number, If the account number is not already in the system, it displays "There is no account with this number". Your choice:2 Enter account number 444 There is no account with this number Please select one of the following: If the account number is valid but it has balance, then it cannot be closed. Your choice: 2 Enter account number 777 Name: Ali Mahmodd The account has balance, cannot be closed If the account number is valid but the account is already closed Your choice: 2 Enter account number456 Name: Noof Khaled The account is already closed Please select one of the following: If the account is there and its status is active ('a') and has no balance, then it is closed by updating its status from ' a ' to ' c ' in the dictionary. Option 3: When the user enters 3 , the system asks for account number. It should check if the account is in the system or not. Your choice: 3 Enter account numberg99 There is no account with this number Please select one of the following: If the account in the system, it will display the customer name. However, it should check if the account is closed or not. Your choice: 3 Enter account number 456 Name: Noof Khaled The account is closed If the account is not closed, it will ask for the amount to be withdrawn, however it should ensure there is enough balance. Your choice: 3 Enter account number123 Name: Ahmed Rashed Enter the amount to withdraw: 2000 Insuffcient fund If everything is OK, it decreases the balance by the input amount (in the dictionary). Your choice:3 Enter account number 123 Name: Ahmed Rashed Enter the amount to withdraw: 700 Your new balance: 300.0 Transaction completed Please select one of the following: The data of this transaction will be append to file "transactions.txt". This data will include the account number, transaction type (here it is ' w '), and the amount "123,w,700" Option 4: When the user enters 4, the system asks for account number. It should check if the account is in the system or not. If the account in the system, it will display the customer name. However, it should check if the account is closed or not. If the account is not closed, it will ask for the amount to be deposited. Your choice:4 Enter account number 123 Name: Ahmed Rashed Enter the amount to deposit:500 Your new balance: 800.0 Transaction completed Please select one of the following: The data of this transaction will be append to file "transactions.txt". This data will include the account number, transaction type (here it is ' d '), and the amount "123,d,500" Option 5 : When the user select 5 , the system will ask for the account number. It ensures that the account in the system. Your choice:5 Enter account number888 There is no account with this number Please select one of the following: Option 6: When the user select 6 , the system will ask for the account number. It ensures that the account in the system. Your choice: 6 Enter account number732 There is no account with this number Please select one of the following: If it is in the system, it displays the last five transaction related to that account. Enter account number 123 Name: Ahmed Rashed The last 5 transactions: d 500.0 w 70. w 10. d 250. w 100.0 Please select one of the following: Option 7: The system will display data of the top five accounts in terms of balance. If the number of accounts less than 5 , it displays all of them. Your choice:7 456 Noof Khaled . 123 Ahmed Rashed 1060.0 777 Ali Mahmodd 4500.0 Please select one of the following: Option 8: The system will save the data in the dictionary to the file "customers.txt" and terminate the main function. Grading your submissions: - Every option is worth 1 point (8 option= 8 points) - The main function (menu) is worth 1 point. You will upload the data from "customers.txt" to the dictionary when the program starts. - 1 point for good code quality: naming variables, naming functions, etc

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago