Create a program that determines if a given number is a valid Visa or Mastercard credit card number. A card number must be 16 digits in length and begin with a 4 (Visa) or 51,52,53,54 or 55 (Mastercard). More importantly to determine if a card number is valid, a checksum (calculation) is performed: 1. Double the value of alternate digits, starting with the first digit 2. Each doubled value becomes individual digits (16 becomes a 1 and a 6) 3. Add the individual digits comprising the products in step 1 to each of the values of the other digits 4. Divide the total by the checksum digit, 10 5. If the checksum digit divides evenly into the total, the card number is valid Examples (Visa card number): 4512113014843252 8+5+2+2+2+1+6+0+2+4+1+6+4+6+2+1+0+2 Sum=54 54/10 leaves a remainder. Thus the card number is invalid. 4512113014643252 8+5+2+2+2+1+6+0+2+4+1+2+4+6+2+1+0+2 Sum=50 50/10 leaves no remainder. Thus the card number is valid.
Info from https://cs.senecac.on.ca/~pro404/Pro404Assignment0.htm https://en.wikipedia.org/wiki/Payment_card_number