lundi 24 mai 2021

Credit Card Number Validation in C++ [closed]

Problem-3: [You may use arrays] Credit Card Number Validation Payment card usage in Egypt is on a steady rise. According to the CBE report there are over 22 million active debit and credit cards in Egypt. This means that vendors accepting payments through these cards need to have a way of validating the card numbers before attempting to process the payment. Luckily there is a systematic way to validate card numbers.

  1. First verify the number of digits is valid (between 14 and 16)
  2. Starting from the right multiply each second digit by 2. If the result of the multiplication is more than 1 digit add the digits together until you have a single digit.
  3. Sum the digits from the previous step.
  4. Sum the digits that had not been multiplied by 2 in step 2
  5. Add the results from step 3 and 4 together
  6. If the result is divisible by 10 then the number is valid Write a program that takes a credit card number as input and checks its validity.

• Implement and make use of the following functions:

o A function that takes a card number and returns its validity (true/false)

o A function that takes a card number and calculates the sum described in points 2 & 3 above.

o A function that takes a card number and calculates the sum described in point 4 above.

o A function that takes an integer and returns it as it is if it’s a single digit, otherwise it returns the sum of the 2 digits.

Aucun commentaire:

Enregistrer un commentaire