Information Technologyacademic

Grasp IT fundamentals quickly with our Study Materials and Revision Notes, making exam prep easier and boosting your scores.

Study Resources
597(116 filtered)

Resource Type

Document Type

Question:

Write a java code using the luhn checksum validation algorithm to check whether a credit card is valid or fake Example of execution of the algorithm: Suppose you want to check that your credit card number is valid. You credit card number is 8273123273510569 . Let's see how to check it: | 0 | 2 | 7 | 3 | 1 | 2 | 3 | 2 | 7 | 3 | 5 | 1 | 0 | 5 | 6 | 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | | | | | | | | | | | | | | | | | First, you are going to double every other number, starting with the first number (here, it is number 8): | 0x2 | 2 | 7x2 | 3 | 1x2 | 2 | 3x2 | 2 | 7x2 | 3 | 5x2 | 1 | 0x2 | 5 | 6x2 | 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | | | | | | | | | | | | | | | | | And you obtain: | 16 | 2 | 14 | 3 | 2 | 2 | 6 | 2 | 14 | 3 | 10 | 1 | 0 | 5 | 12 | 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | | | | | | | | | | | | | | | | | But we do not want double digits, so for every number that now has double digits, we add these digits: | 1+6 | 2 | 1+4 | 3 | 3 | 2 | 6 | 2 | 1+4 | 3 | 1+8 | 1 | 0 | 5 | 1+2 | 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | | | | | | | | | | | | | | | | | And we obtain: | 7 | 2 | 5 | 3 | 2 | 2 | 6 | 2 | 5 | 3 | 1 | 1 | 0 | 5 | 3 | 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | | | | | | | | | | | | | | | | | Now we add all of these numbers: $7+2+5+3+2+2+6+2+5+3+1+1+0+5+3+9=56$ 56 is not a multiple of 10 , so the credit card number was a fake.

...
Solution
Homework
5 months ago
View Answer
Showing 81 to 120 of 794 results