subject
Geography, 25.07.2019 01:30 huangjianhe135

Question 3 (15% of this assignment): (financial: credit card number validation) credit card numbers follow certain patterns: it must have between 13 and 16 digits, and the number must start with: 4 for visa cards 5 for mastercard credit 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 whether a card number is entered correctly or whether a credit card is scanned correctly by a scanner. 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 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 twodigit number, add up the two digits to get a single-digit number. 4388576018402626 2 = 4 2 = 4 4* 2 = 8 * 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 steps 2 and 3. 37 + 38 = 75 5. if the result from step 4 is divisible by 10, the card number is valid; otherwise, it is invalid. for example, the number 4388576018402626 is invalid, but the number 4388576018410707 is valid. write a program that prompts the user to enter a credit card number as an integer. display whether the number is valid or invalid. design your program to use the following functions: # return true if the card number is valid def isvalid (number): # get the result from step 2 def sumofdouble evenplace (number): # return this number if it is a single digit, otherwise, return # the sum of the two digits def getdigit(number): # return sum of odd place digits in number def sumo foddplace (number):

ansver
Answers: 1

Other questions on the subject: Geography

image
Geography, 22.06.2019 21:30, esanchez2002fcb
What happens to rock when acid reacts with it?
Answers: 1
image
Geography, 23.06.2019 01:00, cool8844
Agricultural practices in the united states nearly led to the extinction of the peregrine falcon during the 1950s and 60s.
Answers: 1
image
Geography, 23.06.2019 05:50, Emmylu
Hey this is extremely !international aid debate for geography 10 will mark de brainliest! questions are down below plz put an answer and evidence for it. q1: what are the problems with international aid? q2: what are the alternatives to international aid? q3: what do you think is the best approach to offer international aid? ( answer these questions with credible answers and evidence)
Answers: 1
image
Geography, 23.06.2019 14:00, zetrenne73
Uncle tom's cabin started out as a series of articles printed in the national era, a newspaper.
Answers: 1
You know the right answer?
Question 3 (15% of this assignment): (financial: credit card number validation) credit card number...

Questions in other subjects: