please i need help with solving this problem :
credit card numbers follow certian paterns.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 card
6 for discover card
all credit card numbers are generated following this validity check which can be described as follows (for illustration consider the card number 4388576018402626)
1.double every second digit from right to left. if doubling of a digit results in a two digit number ,add up the two to get a single digit number
2*2=4
2*2=4
4*2=8
1*2=2
6*2=12 (1+2=3)
5*2=10 (1+0=1)
8*2=16 (1+6=7)
4*2=8
2.now add all single digit numbers from step 1
4+4+8+2+3+1+7+8=37
3.add all digits in the odd places from right to left in the card number
6+6+0+8+0+7+8+3=38
4.sum the results from step 2 and 3
37+38=75
5. if the result from step 4 is divisble by 10 the credit card is valid otherwise its invalid for ex the # 4388576018402626 is invalid but the number 4388576018410707 is valid
write a program that promts the user to enter a credit card number as long a integer display wether the number is valid or invalid desing ur prog to use the following functions (these are prototypyes):
/** return true if the card number is valid */
bool isValid(long);
/** get the result from step 2 */
int sumOfDoubleEvenPlace(long);
/** return the same number if it is a single digit otherwise return the sum of the two digits */
int getDigit(int);
/** return sum of odd place digits in the number */
int sumOfOddPlace(long);
/** return if the digit d is a prefix for number */
bool prefixMatched(long number, int d);
/** return the number of digits in d */
int getSize(long d);
/** return the first k nnumber of digits from number , if the number of digits in number is less than k, return number */
long getPrefix(long number, int k).
Wrong forum (you can move the thread yourself).
What do you have?
Tips: When you read a card, read it into a string, not an integer. You don't care what the number is, only what the digits are. To convert a digit character 'n' to an integer n, subtract '0' from it.