I have this code:
# Description:Bank Customer Account Management System
# FUNTION TO RETURN THE ACCOUNT NUMBER FROM A LINE
def get_number(one_line):
return one_line[:6]
# FUNTION TO RETURN THE BALANCE FROM A LINE
def get_balance(one_line):
balance_str = one_line[7:17].strip() # Extract the balance string and remove leading/trailing spaces
return float(balance_str)
# FUNTION TO RETURN THE ACCOUNT NAME FROM A LINE
def get_name(one_line):
name_str = one_line[17:].strip() # Extract the name string and remove leading/trailing spaces
return name_str
# MAIN FUNTION TO PROCESS CUSTOMER TRANSACTIONS
def main():
# ASK THE FILE NAME
fileName = input(‘Enter a file prefix: ‘)
#TRY TO OPEN THE FILE
try:
#OPEN THE INPUT FILE FOR READING
input_file = open(fileName + ‘_old.txt’, ‘r’)
# OPEN THE INPUT FILE FOR APPEND WITH CREATE
output_file = open(fileName + ‘_new.txt’, ‘a+’)
#READ THE FIRST LINE
line = input_file.readline()
#READS TILL 999999
while line.strip() != ‘999999’:
# GETS NUMBER,NAME,BALANCE USING FUNTIONS CREATED
number = get_number(line)
name = get_name(line)
balance = get_balance(line)
#TO CHECK IF CURRENT ACCOUNT CAN BE ADDED TO NEW RECORD
can_add = True
# PRINT CURRENT DETAILS
print(f’verifying input: {number} {balance} {name}’)
#HOLDS THE COMMAND
command = ”
# REPEATS UNLESS USER TYPES A OR C
while True:
# ASK THE COMMAND
command = input(‘Enter a command (a,c,d,w): ‘)
# A TO ADD
if command == ‘a’:
break
# C TO CLOSE
elif command == ‘c’:
# CHECK IF NO BALANCE,THEN CLOSE,OTHERWISE SHOW ERROR
if balance > 0:
print(‘Account not closed because money is still in it.’)
continue
else:
can_add = False
print(‘Account is closed’)
break
# D FOR DEPOSIT
elif command == ‘d’:
amount = 0
while amount <= 0:
try:
amount = float(input('Enter deposit amount: '))
if amount <= 0:
print('INVALID INPUT: Please enter a numeric value greater than 0.')
except ValueError:
print('INVALID INPUT: Please enter a numeric value. ')
balance += amount
# D FOR WITHDRAWL
elif command == 'w':
# VALIDATION LOOP
while True:
try:
amount = float(input('Enter withdrawal amount: '))
break
# IF USER ENTERS OTHER THAN NUMBERS
except ValueError:
print('Withdrawal amount should be a number!')
# REMOVE FROM BALANCE
balance -= amount
#FOR WRONG COMMANDS
else:
print(f'Entered an invalid command {command}')
#ADD TO FILE AND PRINT THE NEW BALANCE
if can_add:
print(f'New balance: {number} {balance} {name}')
output_file.write(f'{number:6} {balance:10.2f} {name}\n')
#READ THE NEW LINE
line = input_file.readline()
#WRTIE THE LAST LINE AS 999999
output_file.write('999999\n')
# IF FILE DOESN'T EXIST SHOW ERROR
except FileNotFoundError:
print(f'The file name {fileName}_old.txt does not exist')
# CALL THE MAIN FUNTION
if __name__ == '__main__':
main()
this must be the ouputEnter a file prefix: customers
Verifying input: 100000 43736.57 Rossum, Guido V.
Enter a command (a,c,d,w): w
Enter withdrawal amount: 1000.00
Enter a command (a,c,d,w): K
Entered an invalid command K.
Enter a command (a,c,d,w): w
Enter withdrawal amount: 500.50
Enter a command (a,c,d,w): d
Enter deposit amount: Two Hundred
INVALID INPUT: Please enter a numeric value.
Enter deposit amount: -1.2
INVALID INPUT: Please enter a numeric value greater than 0.
Enter deposit amount: 200.00
Enter a command (a,c,d,w): a
New balance: 100000 42436.07 Rossum, Guido V.
Verifying input: 100789 5681745.99 Eich, Brendan
Enter a command (a,c,d,w): a
New balance: 100789 5681745.99 Eich, Brendan
Verifying input: 320056 5.01 Ritchi, Dennis MacAlistair.
Enter a command (a,c,d,w): w
Enter withdrawal amount: 5.00
Enter a command (a,c,d,w): c
Account not closed because money is still in it.
Enter a command (a,c,d,w): w
Enter withdrawal amount: 0.01
Enter a command (a,c,d,w): c
Account is closed
Enter a command (a,c,d,w): a
New balance: 320056 0.00 Ritchi, Dennis MacAlistair.
Verifying input: 650430 2398.12 Wall, Larry
Enter a command (a,c,d,w): a
New balance: 650430 2398.12 Wall, Larry ,,,,,,
but the last part doesn't show in my project,I mean this part to the end..please correct the code so that the last part can be in the code
Enter a command (a,c,d,w): a
New balance: 320056 0.00 Ritchi, Dennis MacAlistair.
Verifying input: 650430 2398.12 Wall, Larry
Enter a command (a,c,d,w): a
Requirements: answer
1 CS/CYCS1110 (Python) –Fall 2023 Programming Project #4 Due Date (A Two-week Project) 100 points Wednesday Labs 11/01/22 @ 11:59pm Project Objectives • Use file processing and exception handling. • Use string slicing, operations, searching, testing and manipulating. • Use functions, parameter-passing, return values. • Use if/elif/… else. • Use nesting loops/input validation. • Use incremental development to write and test your program. • NO GLOBAL VARIABLES ALLOWED • Use proper Python naming conventions: variable_name, function_name o Function names must describe what the function does. Project Overview Consider a small bank which uses a text file to maintain information about its customers. Each customer record in that master file is stored on one line of the file and contains the following information: • Account number (6 characters) • Account balance (10 characters) • Account holder (remaining characters on the line) There is exactly one space (blank) between the fields. Account numbers range from 100000 to 999998 (inclusive). The account number 999999 is reserved as a sentinel to mark the end of the customer records (the last line of the file contains “999999”). Account balances range from 0.00 to 9999999.99 (inclusive). Design, implement and test a Python program which allows the bank to interactively enter transactions and produces a new (updated) master file. Deliverables
2 The deliverable for this assignment is the following file: proj04_LastName.py Provides this information in your project: # Project No.: # Author: # Description: Project Structure 1. The program will prompt the user to enter a file name prefix. That prefix will be used to generate the names of the two files by appending “_old.txt” and “_new.txt” to the prefix. For example, the prefix that you should provide is “customers”. The names will be “customers_old.txt” (the old master file) and “customers_new.txt” (the new master file). If the old master file cannot be opened for reading or the new master file cannot be opened for writing, the program will display an appropriate error message and halt. 2. For each customer record in the old master file, the program will: • Display the customer information • Prompt the user for any transactions related to that customer and process those transactions • Write the customer record to the new master file (unless the account has been closed) The list of valid transactions is given below. The format of the new master file will be the same as the format of the old master file: each customer record will contain the fields specified above, and the last line of the file will contain “999999”. 3. The program will recognize the following transaction codes: • d – deposit • w – withdrawal • c – close • a – advance to next customer For code “d”, the program will prompt the user for the amount of money to be deposited into the customer’s account. That amount will be added to the account balance, as long as the new total does not exceed the upper bound. For code “w”, the program will prompt the user for the amount of money to be withdrawn from the customer’s account. That amount will be subtracted from the account balance, as long as the new total does not exceed the lower bound. For code “c”, the program will delete that customer record from the master file, as long as the account balance is zero. When an account is closed, the program will advance to the next customer in the old master file.
3 For code “a”, the program will advance to the next customer in the old master file. If a transaction is not valid, the program will display an appropriate error message and ignore that transaction. 4. The program will assume that an existing master file is error-free. 5. The program will detect, report and recover from all errors related to user inputs. 6. The program will include three functions which help decompose one line of the old master file into the three separate items: • def get_number( one_line ): given one line of the master file, return the account number • def get_balance( one_line ): given one line, return the account balance (as a float) • def get_name( one_line ): given one line, return the account holder’s name (as a string) Project Notes 1. You may not use any collection (such as a list, dictionary, or map) in your program. 2. Be sure to prompt the user for the inputs in the specified order. 3. An example master file is given below, where the first digit of the account number is the first character on each line: 100000 43736.57 Rossum, Guido V. 100789 5681745.99 Eich, Brendan 320056 5.01 Ritchi, Dennis MacAlistair. 650430 2398.12 Wall, Larry 999999 4. An example of a series of user inputs related to the example master file is given below: w 1000.00 w 500.50 d 200.00 a a w 5.01 c a
4 The new master file resulting from that series of transactions is given below: 100000 42436.07 Rossum, Guido V. 100789 5681745.99 Eich, Brendan 650430 2398.12 Wall, Larry 999999 5. Consider the situation where the user enters “a” (and only “a”) for each customer in the old master file. The new master file which results from that series of transactions is identical (character by character) to the old master file. 6. As noted above, you are required to define and use three functions (get_number(), get_balance(), and get_name()) but you may define and use additional functions, if you wish. Iutput File (customers_old.txt)/ It is provided. 100000 43736.57 Rossum, Guido V. 100789 5681745.99 Eich, Brendan 320056 5.01 Ritchi, Dennis MacAlistair. 650430 2398.12 Wall, Larry 999999 Sample Output/Processing Input/Output Files (use EXACT format – and NO HARDCODING of the data itself) First Sample Output Enter a file prefix: custooomers The file name custooomers_old.txt does not exist Second Sample Output Enter a file prefix: customers Verifying input: 100000 43736.57 Rossum, Guido V. Enter a command (a,c,d,w): w Enter withdrawal amount: 1000.00 Enter a command (a,c,d,w): K Entered an invalid command K. Enter a command (a,c,d,w): w Enter withdrawal amount: 500.50 Enter a command (a,c,d,w): d Enter deposit amount: Two Hundred INVALID INPUT: Please enter a numeric value.
5 Enter deposit amount: -1.2 INVALID INPUT: Please enter a numeric value greater than 0. Enter deposit amount: 200.00 Enter a command (a,c,d,w): a New balance: 100000 42436.07 Rossum, Guido V. Verifying input: 100789 5681745.99 Eich, Brendan Enter a command (a,c,d,w): a New balance: 100789 5681745.99 Eich, Brendan Verifying input: 320056 5.01 Ritchi, Dennis MacAlistair. Enter a command (a,c,d,w): w Enter withdrawal amount: 5.00 Enter a command (a,c,d,w): c Account not closed because money is still in it. Enter a command (a,c,d,w): w Enter withdrawal amount: 0.01 Enter a command (a,c,d,w): c Account is closed Enter a command (a,c,d,w): a New balance: 320056 0.00 Ritchi, Dennis MacAlistair. Verifying input: 650430 2398.12 Wall, Larry Enter a command (a,c,d,w): a New balance: 650430 2398.12 Wall, Larry Output File (customers_new.txt) 100000 42436.07 Rossum, Guido V. 100789 5681745.99 Eich, Brendan 650430 2398.12 Wall, Larry 999999
We are a professional custom writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework.
Yes. We have posted over our previous orders to display our experience. Since we have done this question before, we can also do it for you. To make sure we do it perfectly, please fill our Order Form. Filling the order form correctly will assist our team in referencing, specifications and future communication.
1. Click on the “Place order tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
2. Fill in your paper’s requirements in the "PAPER INFORMATION" section and click “PRICE CALCULATION” at the bottom to calculate your order price.
3. Fill in your paper’s academic level, deadline and the required number of pages from the drop-down menus.
4. Click “FINAL STEP” to enter your registration details and get an account with us for record keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
5. From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.
Need help with this assignment?
Order it here claim 25% discount
Discount Code: SAVE25