Java Reference
In-Depth Information
file), add the dollar amount in the transaction record to the current balance in the mas-
ter record, and write the "newmast.txt" record. (Assume that purchases are indicated
by positive amounts in the transaction file and payments by negative amounts.) When
there's a master record for a particular account, but no corresponding transaction re-
cord, merely write the master record to "newmast.txt" . When there's a transaction re-
cord, but no corresponding master record, print to a log file the message "Unmatched
transaction record for account number " (fill in the account number from the trans-
action record). The log file should be a text file named "log.txt" .
15.5 (File Matching with Multiple Transactions) It's possible (and actually common) to have
several transaction records with the same record key. This situation occurs, for example, when a cus-
tomer makes several purchases and cash payments during a business period. Rewrite your accounts
receivable file-matching program from Exercise 15.4 to provide for the possibility of handling sev-
eral transaction records with the same record key. Modify the test data of CreateData.java to in-
clude the additional transaction records in Fig. 15.16.
Account number
Dollar amount
300
83.89
700
80.78
700
1.53
Fig. 15.16 | Additional transaction records.
15.6 (File Matching with Object Serialization) Recreate your solution for Exercise 15.5 using
object serialization. Use the statements from Exercise 15.3 as your basis for this program. You may
want to create applications to read the data stored in the .ser files—the code in Section 15.5.2 can
be modified for this purpose.
15.7 (Telephone-Number Word Generator) Standard telephone keypads contain the digits zero
through nine. The numbers two through nine each have three letters associated with them
(Fig. 15.17). Many people find it difficult to memorize phone numbers, so they use the correspon-
dence between digits and letters to develop seven-letter words that correspond to their phone num-
bers. For example, a person whose telephone number is 686-2377 might use the correspondence
indicated in Fig. 15.17 to develop the seven-letter word “NUMBERS.” Every seven-letter word cor-
responds to exactly one seven-digit telephone number. A restaurant wishing to increase its takeout
business could surely do so with the number 825-3688 (i.e., “TAKEOUT”).
Digit
Letters
Digit
Letters
Digit
Letters
2
A B C
5
J K L
8
T U V
3
D E F
6
M N O
9
W X Y
4
G H I
7
P R S
Fig. 15.17 | Telephone keypad digits and letters.
Every seven-letter phone number corresponds to many different seven-letter words, but most
of these words represent unrecognizable juxtapositions of letters. It's possible, however, that the
 
 
Search WWH ::




Custom Search