Question: Write a C + + code: credit card number follow certain patterns. a credit card number musthave between 1 3 and 1 6 digits. it

Write a C++ code: credit card number follow certain patterns. a credit card number musthave between 13 and 16 digits. it must start with 4 for visa cards, 5 for master cards, 37 for american express cards, 6 for discover cards. in 1954, hans luhn of IBM proposed an algorithm for validating credit card numbers. the algorithm is useful to determine if a card number is entered correctly or if a credit cards is scanned correctly by a scanner. almost all credit card numbers are generated following this validity check, commonly known as the luhn check or the mod 10 check, which can be described as f (for illustration consider the card number 4388576018402626): 1. double every second digit from right to left. if doubling of a digit results in a twodigit number, add up the two digits to get a singledigit 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=82. now add all singledigit number from step 1.4+4+8+2+3+1+7+8=373. add all digits in the odd places from right to left in the card number 6+6+0+8+0+7+8+3=384. sum the results from step 2 and 3.37+38=755. if the result from step 4 is divisible by 10, the card nuber is valid; otherwise it is invalid. for example, the number 4388576018402626 is invalid but 4388576018410707 or 4147200059780942 is valid.write a program that prompts the user to enter a credit card number as a long integer. display whether the number is valid or invalid. the code requirements are: 1: your code will create a class called MyClass 2: there are two ways to define functions/methods that belong to a class: inside class definitions or outside class definitions. you will use the second for this programming exercise. this means that you will declare all the methods/functions inside the class. but the definitions for each will be done outside of the class. 3: my class must contain the followingmtheods/functions: long MyClass::getSize(long d) and long MyClass:getPrefix(long number, int k), and bool MyClass::prefixMatched (long number, int d), and int MyClass::getDigit(int number), and int MyClass::sumOfDoubleEvenPlace(long number), and int MyClass::sumOffOddPlace(long number), and bool MyClass::isValid(long number)4: now for the main() function: int main(){ MyClass myObj; // create an object of my class cout<< this program will use the luhn check to validate a credit card number <> number // now call the fist member function isValid(number)-above //process the outcome of above}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!