Question: qWrite a C + + code: credit card number follow certain patterns. a credit card number musthave between 1 3 and 1 6 digits .
qWrite a Ccode: credit card number follow certain patterns. a credit card number musthave between and digits it must start with for visa cards, for master cards, for american express cards, for discover cards. in 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 check, which can be described as f for illustration consider the card number : 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. now add all singledigit number from step add all digits in the odd places from right to left in the card numbersum the results from step and if the result from step is divisible by the card nuber is valid; otherwise it is invalid. for example, the number is invalid but or 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: : your code will create a class called MyClass : there are two ways to define functionsmethods 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 methodsfunctions inside the class. but the definitions for each will be done outside of the class. : my class must contain the following methodsfunctions: long MyClass::getSizelong d and long MyClass:getPrefixlong number, int k and bool MyClass::prefixMatched long number, int d and int MyClass::getDigitint number and int MyClass::sumOfDoubleEvenPlacelong number and int MyClass::sumOffOddPlacelong number and bool MyClass::isValidlong number: now for the main function: int mainMyClass myObj; create an object of my class cout number now call the fist member function isValidnumberabove process the outcome of above document every block of the program.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
