Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#5 Charge Account Validation Save the file as ch7_ex2.py Write a program that reads the account numbers from a file into a list. The user

#5 Charge Account Validation Save the file as ch7_ex2.py Write a program that reads the account numbers from a file into a list. The user is asked to enter a charge account number, and the program should determine if the number is valid by searching the list. If the number is in the list, the program should display a message indicating the number is valid. If the number is not in the list, the program should show the number is invalid. The program must: Declare the variable test_acct inside the main function and initialize it as an empty string. Include a try block inside the main function that handles IOError exceptions. Open the text file for reading. Read all the account numbers into a list. Close the file. Reference the user-entered account number and display whether or not the account is valid. Test the program using the following text file (download from BlackBoard assignment page): 7-2-accounts.txt The output should look like these invalid and valid entries: Enter the account number to be validated: 1234567 Account number 1234567 is not valid. Enter the account number to be validated: 5946311 Account number 5946311 is valid.

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions