Information Technology Reference
In-Depth Information
The file that we want to consider is a file for checking at the bank. For now it will
consist of just a few fields, account number, last name, first name, middle initial, street
address, city, state, zip code and balance. Using someone's social security number -
because of identity theft - is not a good idea. In some cases, the computer will generate an
account number - and even let the customer know what it is. In our system, the account
number will be a nine-digit field greater than nine.
Both the first and last names must consist of letters of the alphabet, the space,
apostrophe, period and hyphen only. This accommodates Billy Bob Thornton, Tom
O'Brien, Jill St. John and Olivia Newton-John. The first name is limited to fifteen
characters while the last name is restricted to eighteen. That should be enough characters.
The middle initial must be A through Z , but it can also be left blank. The street address is
limited to twenty-five characters and has the same restrictions as the name, except
numbers are also allowed as well as the comma. If you live at 10 ½ Main Street, good
luck. City must be no more than fifteen characters and these must consist only of letters
of the alphabet, the period, space and hyphen.
The state must be exactly two characters and it must be the valid abbreviation for
one of the fifty. The zip code must be a five digit numeric field. The balance will be a
signed numeric field having eight digits, six to the left of the decimal point and two to the
right. If you have a balance of over $999,999, it shouldn't be in a checking account. In
fact this bank may even be more restrictive and caring about the customer - that could
happen - as large balances might result in letters being sent out notifying customers that
they may want to consider a certificate of deposit or the idea of buying stock.
Our file is the account file and if I want to read it in a program, I will specify the
variable
acctfile
that represents a file which the program can read. How this is done will be shown when
we get to the program. For now we need to worry about the fields that make up the file.
We have to spell out the names of the fields, their sizes, where they are in the record and
what type each field is. To save space one field will follow the other so we'll define a
structure, which will refer to the file, the record and each field.
We'll define a file and its composition so that we know the makeup of a typical
record. That way, we'll know where each field should be. We certainly don't want the
first record to have the account number at the beginning followed by the last name and
then the second record have the first name directly after the account number. That
scenario will make it impossible to process the file. In our account number file, the
account number will start in position 1 of the record and end in position 9, last name will
start in position 10 and end in position 27, first name will begin in position 28 and end in
position 42 and so forth until we get to balance, which ends in position 99. This will be
the case for each record on the file and it means we can find the data we want where it
should be.
We could have put commas as separators between the fields and accomplished the
same result but what happens when one of the fields has a comma in it? That could mess
us up so our method will be better. We start by defining a file and its structure. The
Search WWH ::




Custom Search