Question
Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits. The starting numbers are: 4 for Visa cards,
Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits. The starting numbers are: 4 for Visa cards, 5 for MasterCard cards, 37 for American Express cards, and 6 for Discover cards. Example: Validating 4388576018402626 a) Double every second digit from right to left. If doubling of a digit results in a two-digit number, add the two digits to get a single digit number. b) Now add all single-digit numbers from Step a: 4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37 c) Add all digits in the odd places from right to left in the card number: 6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38 d) Sum the results from Step b and Step c: 37 + 38 = 75 e) If the result from Step d is divisible by 10, the card number is valid; otherwise, it is invalid. Please implement Credit Card Number Validation: 1. Function main is provided. Please implement isvalidcc and other functions which you may add to the program. 2. Please do not change function main 3. Your program must produce identical output: ASMT02_PB_Run.pdf
use the following codes:
bool isvalidcc(const string&);
int main() { // // PLEASE DO NOT CHANGE function main // vector
int i; vector
for (i = 1, itr = cardnumbers.begin(); itr != cardnumbers.end(); ++itr, i++) { cout << setw(2) << i << " " << setw(17) << *itr << ((isvalidcc(*itr)) ? " is valid" : " is not valid") << endl; }
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started