Write a credit card validation program credit card numbers


Write a Credit card validation program. Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits.

It must start with
4 for Visa cards,
5 for Master cards,
37 for American Express cards, and
6 for Discover cards.
In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or
whether a credit card is scanned correctly by a scanner. Credit card numbers are generated following this validity check, commonly known as theLuhn check or the Mod 10 check.which can be described as follows :
1.. Double every second digit from right to left. If doubling of a digit results in a 2-digit number, add up the two digits to get a single-digit number.
Look at this 16 - digit number: 4 3 8 8 5 7 6 0 1 8 4 0 2 6 2 6
4 * 2 = 8
8 * 2 = 16 -> 1 + 6 = 7
5 * 2 = 10 -> 1 + 0 = 1
6 * 2 = 12 -> 1 + 2 = 3
1 * 2 = 2
4 * 2 = 8
2 * 2 = 4
2 * 2 = 4
2. Add all single-digit numbers from Step 1. In this case the sum is 37
3. Add all digits in the odd places from right to left in the card number, in this case 38
4. Sum the results from Step 2 & 3 , in this case, 37 + 38 = 75
E. Display if the number is valid or not.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a credit card validation program credit card numbers
Reference No:- TGS02384223

Now Priced at $15 (50% Discount)

Recommended (91%)

Rated (4.3/5)