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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started