Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python only, please follow pseudocode for customer and account. make sure the output is coming correct thank you. Read everything before doing anything! In

in python only,

please follow pseudocode for customer and account. make sure the output is coming correct thank you.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Read everything before doing anything! In this project, you will write two files: a class that represents a bank account and a program that works ike an ATM for bank accounts. The Bank Account Class In a file named account.py, create an Account class. An account object has these attributes: acct_number: the account number (an integer) name : the account holder's name pin: the account holder's PIN, which is a four- character string, since it can have leading zeros. balance : the current balance in the account, which is a float Implement these methods: _init__(self, acct_number, name, pin, balance) The constructor _str_(self) Returns a string giving the account ID, name, PIN, and balance, separated by colons. Do not use formato on the balance; you want to keep the number as accurate as possible. deposit(self, amount) Adds the given amount (a float ) to the current balance. If the amount is negative. the balance 0 7:19 0 MP @ 95% balance. If the amount is negative, the balance must not be changed; otherwise, the balance attribute is updated to reflect the deposit. This method returns the updated balance. withdraw(self, amount) Withdraws the given amount (a float) from the current balance. If the amount is negative or greater than the current balance, the balance must not be changed; otherwise, the balance attribute is updated to reflect the withdrawal. This method returns the updated balance. Note that deposit and withdraw() do not print error messages if they get incorrect input; they simply ignore it. It is up to the program that calls these functions to provide the error messages for the user of the program. The Customer Program Write a program named lastname_firstname_customer.py that provides an "ATM" interface to a set of bank accounts. Use this accounts.dat file to set up the initial set of accounts. Each line of the text file has an account ID, name, PIN, and starting balance, separated by colons. Your program must first read the account data file and build a dictionary with the account number as the key and the Account object as the value. The program will repeatedly ask for an account number (or ENTER to quit). This is equivalent to inserting an ATM card. Repeat until the account number is valid. Once you have an account number, prompt for the PIN. The PIN must have exactly four digits. (Hint: use isnumerico ) If the customer presses just ENTER, presume that the customer doesn't want to do any transactions. If the PIN is given incorrectly three times, then 7:19 0 ME @ 95% i TOMTIDEN FOR ENTERWYU TI QUIVCLICTICE inserting an ATM card. Repeat until the account number is valid. Once you have an account number, prompt for the PIN. The PIN must have exactly four digits. (Hint: use isnumerico ) If the customer presses just ENTER, presume that the customer doesn't want to do any transactions. If the PIN is given incorrectly three times, then return to the account number prompt. Once you have a valid PIN, print a message that greets the customer by name. Then repeatedly ask the customer if they want to deposit, withdraw, or finish the transactions. If the customer wishes to deposit, ask for the amount until you get a number greater than or equal to zero; then perform the transaction and display the balance. Print an appropriate message for invalid input. If the customer wishes to withdraw, ask for the amount until you get a number greater than or equal to zero and less than or equal to the current balance; then perform the transaction and display the balance. Print an appropriate message for invalid input. If the customer is finished, print a message to say goodbye to the customer, write the entire account data structure back to disk, and return to the account number prompt. (This is equivalent to giving the customer their card back), This program must print all monetary amounts preceded by a dollar sign and with two digits after the decimal point. Sample Output Here is what your program output might look like: 7:19 0 ME ON S95% Enter account number or ENTER to quit): 1234 Invalid account number Enter account number (or ENTER to quit): 1062 Enter a 4-digit PIN: 1111 Enter a 4-digit PIN: 2222 Enter a 4-digit PIN: 3333 Sorry, could not validate you as a customer. Enter account number or ENTER to quit): 1062 Enter a 4-digit PIN: 6717 Welcome, Roz Chast! Your current balance is $1853.22 Deposit, Withdraw, or Finish: d Enter amount to deposit: $-5 Amount cannot be negative. Enter amount to deposit: $1000 Your balance is now $2853.22 Deposit, Withdraw, or Finish: w Enter amount to withdraw: $2870 Amount cannot be negative or greater than bal ance Enter amount to withdraw: $500.11 Your balance is now $2353.11 Deposit, withdraw, or Finish: f Thank you for banking with us, Roz Chast Enter account number (or ENTER to quit): 1062 Enter a 4-digit PIN: 0174 Welcome, Georges Remi! Your current balance i 5 $3571.85. Deposit, withdraw, or Finish: x That is not a valid option. Deposit, Withdraw, or Finish: d Enter amount to deposit: $25.15 Your balance is now $3597.00 Deposit, Withdraw, or Finish: f Thank you for banking with us, Georges Remi Enter account number (or ENTER to quit): Pseudocode Here is some pseudocode for the accounts and customer portions of the program. - ZOOM + K | 10625: Christina Plaka: 9113:456.71 10626: Roz Chast: 6717:1853.22 10627: Georges Remi: 0174:3571.85 10628: Raquel Corcoles: 5512:783.00 10629: Eiichiro Oda: 0505:854.02 10630 : Scott McCloud: 8148:2733.96 - ZOOM + Account class Each account has an account number (act number), account holder's PIN (4 character string) and current balance class Account: definit (self, acct number, name, pin, balance): Intialize corresponding members of the Account object being created. def str (self): Return a string that has the account number, account holder's nane, PIN, and balance; separated by colons." def deposit(self, amount): Add the amount to the balance if the anount is greater than or equal to zero. If not, leave the object untouched. def withdraw(self, amount): Subtract the amount from the balance if the amount is greater than or equal to zero and less than or equal to the current balance. If not, leave the object untouched. omer_pseudocode.py load customer_pseudocode.py (4.51 KB) of 3 0 - ZOOM + Customer program This program constructs a dictionary of accounts keyed by account number from a text file named accounts.dat. This file has one account per Line, with the account number, customer name, PIN, and balance, separated by colons. For example, one entry night be: 10627: Georges Remi: 0174: 3571.85 # # The program then repeatedly allows customers to log in with account number and PIN. (three tries). If user presses ENTER when asked for account number, the program ends. # # Once authenticated, the customer can deposit, withdraw, or finish When the customer finishes, the program writes the dictionary back to the accounts.dat file in the same format as previously described import account # Global variable: the account dictionary accounts 0 def create dictionary(): ***Create dictionary of accounts from a data file that has acct number, name, pin, and current balance separated by coton infile open('accounts.dat ) for line in infile: strip leading and trailing spaces, and split on create a new Account object with the given data add it to the accounts dictionary with the account number as a key. infile.close() def write accounts(): write back the accounts.dat file after customer finishes transaction get list of keys for the accounts dictionary sort that list open the accounts.dat file for writing tomer_pseudocode.py mload customer_pseudocode.py (4.51 KB) of 3 0 - ZOOM + CUSCO def write accounts(): Write back the accounts.dat file after customer finishes transaction get list of keys for the accounts dictionary sort that list open the accounts.dat file for writing for each key in the key list: # write str(accounts key])." ' to the file close the file def input account number(): Return an account number as a string * result input('Enter account number or ENTER to quit): while result is not null and account number is in the dictionary print("Invalid account number.') result = input("Enter account number or ENTER to quit): ') return result def input pin(): Return a 4.digit PIN as a string M repeatedly ask for a 4.digit PIN W while the answer isn't exactly four digits, keep asking M return the answer def login account number): tomer_pseudocode.py nload customer_pseudocode.py (4.51 KB) of 3 0 - ZOOM + Tree account number input account number() while account number if login account number): account accounts.get(account number print("welcome, Count.name your current balance is show balance Account). . sepe) de transactions (account) else: print("Sorry, could not validate you as a customer.) account_number = Input_account_number()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions