The Question
Write a program called Q1.java that prompts for and then reads in a series
of whitespace separated strings (until there are no more strings to read).
For each string read, your program should determine whether that string
could be a valid number for a credit card (type.lib.CreditCard), i.e.
whether that string could ever be returned by a successful call to the
getNumber() method of the type.lib.CreditCard class. See the API
for the CreditCard class, in particular the introduction ("This class
encapsulates ... ").
The output should conform to that in the sample run of a correct program
shown below.
Note that, in this sample runs, the % sign is not part of the program output.
Sample Run
%
indigo 335 % java Q1
Enter credit card number strings separated by whitespace:
000000-0 100000-8 999999-0 9999999-0 abc999-0 123456-6 1234-56 1234566
number ok
number ok
number ok
error
error
number ok
error
error
181818-0 181818-1
number ok
error
%
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 labtest2T1 Q1.java