Final Project – Credit card numbers and the case of Mobius Duck

In this project, you are assisting an investigation. The investigator asked you to help him determine the

validity of credit card numbers located in a case of Mobius Duck, case number 20150510-001.

Your task is to:

– Read the data listed below “Data to Evaluate” from a file.

– Evaluate each number to see if they are representing a possible credit card number.

– Validate each credit card number to see if they are a valid number.

– Store the valid numbers and invalid numbers in a separate array.

– Write the contents of validated credit card number array into a file called “valid_cards.txt”.

– Write the invalid credit card number array to a file called “invalid_numbers.txt”.

– Make sure to include the issuer for each group of credit card numbers identified.

– Your application should work with any number of credit card entries.

Turn in:

– Source code ( .java ) files of all classes and driver class.

– Completed UML for application classes.

– Flow chart for every method that contains beyond sequential logic flow.

– Generated javadocs structure.

– Input and output files

Grading:

– Naming standard followed for project files – 2%

– Input and output files – 2%

– Javadoc structure – 5%

– Project compiled without error – 91%

– Proper use of internal comments, docstrings, and tags – 5%

– Self documenting field, identifier, method, static, final, and class identifiers – 5%

– Properly validated input and output files – 5%

– Properly used arrays to store data – 5%

– Correct output calculated by the Luhn algorithm and card number issuer identified – 71%

Extra Credit:

- Implement the full Issuer IIN Range instead of the simplified list.

How to validate Credit Card Numbers?

Most credit card number can be validated using the Luhn algorithm, which is more or a less a glorified Modulo

10 formula!

The Luhn Formula:

• Drop the last digit from the number. The last digit is what we want to check against

• Reverse the numbers

• Multiply the digits in odd positions (1, 3, 5, etc.) by 2 and subtract 9 to all any result higher than 9

• Add all the numbers together

• The check digit (the last number of the card) is the amount that you would need to add to get a multiple

of 10 (Modulo 10)

Our Solution

public boolean validate(String cardNumber) {

int sum = 0;

boolean oddD = false;

for (int i = cardNumber.length() – 1; i >= 0; i–) {

// Reading the string

int oddDigit = Integer.parseInt(cardNumber.substring(i, i + 1));

// When the digits are in the odd position

if (oddD) {

// Odd position digits are multiplied by 2

oddDigit *= 2;

// Odd positions greater than 9

if (oddDigit > 9) {

// Get subtracted by 9

oddDigit = (oddDigit % 10) + 1;

}

}

// add all the numbers together

….

….

}