Write a program that reads in a list of accounts from a file

Assignment Help Computer Engineering
Reference no: EM132158985

Use python :

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

Reference no: EM132158985

Questions Cloud

Suppose that you randomly select 1 rat from this colony : Of the 26 males, 16 are white, and 10 are spotted. Suppose that you randomly select 1 rat from this colony.
Implement and test a prototype for rsa : Implement and test a prototype for RSA, an asymmetric encryption system.
Obtaining a white male : What is the probability, as a proportion, of obtaining a white male? [answers to 2 decimal places]
What is the conditional probability : A diagnosis for a test is such that it (correctly) detects the disease in 86% of the individuals who actually have the disease. Also, if a person does not have
Write a program that reads in a list of accounts from a file : Write a program that reads in a list of accounts from a file, and then allows the user to enter transactions for each account.
What is the decay rate : The average lifetime of a certain new cell phone is 3 years. The manufacturer will replace any cell phone failing within 2 years of the date of purchase.
Plot the logistic loss or negative log likelihood : Train your model on each subset selected, test it on the corresponding test set (i.e. test_0_1 or test_3_5)
Represent the sample mean level of support : The study provided the following information on the distribution of levels of support for? sustainability: µ=64?, s=23. Now consider a random sample
Displays the number of the files in the directory : Use a recursive approach to write a program that prompts the user to enter a directory and Displays the number of the files in the directory.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd