The Question

Write a program called Q1.java, which reads a series of lines from standard input (the keyboard) until there are no more lines to read. Each line will hold 3 pieces information about a credit card (type.lib.CreditCard), namely the card number, the cardholder's name and the credit limit. These will be separated by colons ':'. You may assume that each input line is well formed; i.e. you do not have to check whether there are indeed 3 items on each line or whether each is of the required type or whether the values fall withing the required range.

Your program should use these lines to create credit cards and try to add them to an initially empty GlobalCredit instance (type.lib.GlobalCredit). When all lines have been read, print out information about the GlobalCredit instance as shown in the sample output below.

A complication: an attempt to add a credit card with the same number as one already in the GlobalCredit instance will fail. For this exercise, you will also enforce the restriction that no two cards in the GlobalCredit instance can have exactly the same cardholder name. If you read a line with exactly the same name as that on a card already in the GlobalCredit instance, then that line should be ignored.

Sample Run

%
% java Q1
For each credit card enter a line with colon-separated number:cardholder name:credit limit
123456:David Smith:5000
234567:William Roy:3000
345678:David James Bowie:10000
123456:Dudley Double:1000
456789:William Roy:2000
567890:Alex MacDonnell:2000
678901:Magnus Eisengrim:9999

The created GlobalCredit instance:
    NUMBER      LIMIT NAME
  678901-5    9999.00 Magnus Eisengrim
  345678-3   10000.00 David James Bowie
  123456-6    5000.00 David Smith
  234567-0    3000.00 William Roy
  567890-1    2000.00 Alex MacDonnell
%
%

Useful APIs

Here (again) are the common APIs that you may access:

Java 1.5 API
Type API

Submitting Your Work

Here is the command to submit your work (further details regarding the submit command can also be obtained by typing man submit
Once again, you are encouraged to submit regularly. Newer submissions overwrite older ones.

submit 1020 labtest2F1 Q1.java