Question: You are to write a Java program that reads in a series of digit sequences from a file whose name is entered by the user.

You are to write a Java program that reads in a series of digit sequences from a file whose name is entered by the user. Your program must identify whether each is a valid credit card sequence, i.e., whether it is of the correct format according to the Luhn Formula. Your program should display each sequence on a line, followed by its classification: either VALID or INVALID. there will be one digit sequence per line, and there may be spaces within the sequence (which are ignored with respect to the Luhn Formula). Any sequence that contains a character other than a digit or space is considered invalid.

If the file contains:

4289 0298 7524 0023 4289 0298 7524 0026 313 4890 444 2000 120 42 89 01 44 32 58 99 4 42 89 01 44 32 58 99 40 4289 0144 3258 9941 1234-5678-9876-5432

the program should output:

4289 0298 7524 0023 VALID 4289 0298 7524 0026 INVALID 313 4890 444 2000 120 VALID 42 89 01 44 32 58 99 4 VALID 42 89 01 44 32 58 99 40 INVALID 4289 0144 3258 9941 INVALID 1234-5678-9876-5432 INVALID

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!