Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python 3: Write a program that reads in a list of accounts from a file, and then allows the user to enter transactions for

Use python 3:

Write a program that reads in a list of accounts from a file, and then allows the user to enter transactions for each account. The file accounts.txt contains a list of accounts with initial balances. As the program runs, it should ask the user for the name of an account, and the amount of money to deposit or withdraw from the account. After each transaction, the program should print the amount remaining in the account. If the accounts.txt file is missing, the program should exit with an error message. If any account has a non-float value for the balance, the program should display an error and not add that account. If a non-float is entered for a transaction, or if the account name entered does not exist, the program should print an error message and cancel the transaction. The program should exit when the user enters Stop for an account name. Note that the accounts.txt file DOES NOT need to be updated by the program. Input File Example Bob:234.70 Tom Johnson:791.56 Anna:3260.55 Jill:-23.76 Mike Smith:Not_A_Float! . . . When the line: Mike Smith:Not_A_Float! is encountered, the program should print: Account for Mike Smith not added: illegal value for balance If the input file is missing, the program should print: Input file not found, program will exit An example of interaction with the program could look like this: Enter account name, or 'Stop' to exit: Bob Enter transaction amount: -45.23 New balance for account Bob: 189.47 Enter account name, or 'Stop' to exit: Bob Enter transaction amount: 117.90

New balance for account Bob: 307.37 Enter account name, or 'Stop' to exit: Anna Enter transaction amount: this_is_not_a_float Illegal value for transaction, transaction canceled Enter account name, or 'Stop' to exit: Mike Smith Account does not exist, transaction canceled Enter account name, or 'Stop' to exit: Stop

accounts.txt:

Bob:234.70 Tom Johnson:791.56 Anna:3260.55 Jill:-23.76 Mike Smith:Not_A_Float! Timothy James Lee:1022.71 Sarah Smith:-567.30 George:eleven Vanessa:43781.43 Mr. X:417.99

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions