Bank cards are issued to clients of ABC Bank to enter into transactions on their accounts. A new type of card that they issue has a card number which consists of sixteen digits that are unique to each card issued. The card number is compiled in such a way that certain basic information is encoded

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Topic Video
Question

Bank cards are issued to clients of ABC Bank to

enter into transactions on their accounts. A new type

of card that they issue has a card number which

consists of sixteen digits that are unique to each

card issued. The card number is compiled in such a

way that certain basic information is encoded

therein by grouping certain digits.

The composition of a card number is as follows:

Card number composition

0 3 1 9 2 1 1 1 1 0 0 8 2 3 6 8

T E A

Where:

T – Type

E – Expiry date

A – Account number

The first four digits (T) represent the card type and

issue year in the format

TTYY

where T is the type (see Table 3.1) and Y is the year,

so in the example is 0319 = Diner's club, issued in

2019.

The following four digits (E) indicate the card's

expiry date in the format

YYMM

Where Y is the year and M is the Month of the year,

so in the example 2111 = 2021, 11th month.

The last eight digits (A) indicate the card's account

number. The series representing the account

number starts with 1 or 0:

0XXXXXXX – Debit account

1XXXXXXX – Credit account

so, in the example 10082368 = Credit account.

Now write a Python program that can read a list of

card numbers from a text file and analyse the

card numbers to extract the encoded data as shown

above for each number. The decoded data must be

written to a text file.

See Figures 3.1 and 3.2 for example output.

Questions 3.1-3.4 must be completed, in order, in

one Python file to create a complete, working

program.

Question 3.1 [10]

Write a function, ReadFile(), that reads the contents

of a text file and stores it in a list. The text file,

Data.txt, is provided and its content is presented in

Table 3.2.

The Data.txt file is saved under “K:\Data.txt”. Make

a backup of the file before the file is accessed by the

program.

Each line in the text file consists of one card

number.

The function receives one parameter: A string list for

where each individual entry from the text file must

be stored. The list is passed by reference to the

function.

The function returns the number of lines that were

read from the text file to the calling statement. If the

file cannot be read, an error message should be

displayed, and the program should close without

any further execution.

NB! – If the function in Question 3.1 does not

function correctly, a list may be explicitly created in

the main program as if the function has read the

contents from the file. This list is to be used in the

following questions

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning