Determine whether a given credit card number is valid or not

Assignment Help Management Information Sys
Reference no: EM131323999

Question

Credit card numbers follow certain patterns. 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 cards, and 6 for Discover cards. In 1954, Hans Luhn of IBM proposed the following algorithm for validating credit card numbers:

a. Double every second digit from right to left (e.g., if number is 3 => 3 * 2 => 6) and add them together.

b. If this doubling results in a two-digit number, then add the two digits to get a single-digit number (e.g., if number is 5 => 5 * 2 => 10 => 1+0 => 1).

So, for the credit card number 4388576018402626, doubling all second digits from the right results in (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).

This totals to 4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37. Add all digits in the odd places from right to left.

The leftmost digit of the credit card number is at index 0; 6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38.

Add results from steps (a) and (b) and see if divisible by 10. If it is, then the card number is valid; otherwise invalid. 37 + 38 = 75 is not divisible by 10, so it is an invalid credit card number.

Implement Luhn's algorithm in a program to determine whether a given credit card number is valid or not. You must test if the number of digits in the input is in the valid range (13 to 16), run Luhn's algorithm to test its validity, and if it is valid, print the name of the company that offers that credit card number.

Reference no: EM131323999

Questions Cloud

Write a c program that request the name of cartoon character : Write a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each): a. Displays it enclosed in double quotes.
What is the speed and velocity of a car : What is the speed and velocity of a car that travels 32 meters to the east and 12 meters in the same direction? the total time of travel in 3.0 seconds
What is the projected amount of fixed costs : A company is considering a project with a cash break-even point of 31,422 units. The selling price is $39 a unit, the variable cost per unit is $27, and depreciation is $14,000. What is the projected amount of fixed costs?
What is the company cost of capital and equity beta : The company ROC has been financing its operations with equity only. That is, it is fully financed with equity. The expected return on their equity is currently 8%, the share price is $20 per share, and there are 25 million shares outstanding. What is..
Determine whether a given credit card number is valid or not : Implement Luhn's algorithm in a program to determine whether a given credit card number is valid or not. You must test if the number of digits in the input is in the valid range (13 to 16).
Create semi-annual operating budget : The Miami Art Museum (MAM) is working on the budgets for the 2008 fiscal year, which runs from January 1 through December 31. During the first half of FY08 MAM expects its revenues and expenses to be relatively the same as the 2007 fiscal year; Creat..
Discuss how each competency and condition leads : Discuss how each competency and condition leads to either task and/or personal connection by contributing to goal clarity, loyalty, trust, or information sharing -  Explain your reasons with reference to the background materials and examples from t..
What is the process associated with becoming certified : What is the process associated with becoming certified? What is the estimated amount of time necessary to prepare for the certification exam? What requirements are associated with the certification?
Calculate the predetermined overhead rate : ACC00146 - Management Accounting Assignment. Estimated or budgeted cost and operating data for three companies for 2013 are given below: Calculate the predetermined overhead rate to be used in each company during 2013

Reviews

Write a Review

Management Information Sys Questions & Answers

  Information technology and the changing fabric

Illustrations of concepts from organizational structure, organizational power and politics and organizational culture.

  Case study: software-as-a-service goes mainstream

Explain the questions based on case study. case study - salesforce.com: software-as-a-service goes mainstream

  Research proposal on cloud computing

The usage and influence of outsourcing and cloud computing on Management Information Systems is the proposed topic of the research project.

  Host an e-commerce site for a small start-up company

This paper will help develop internet skills in commercial services for hosting an e-commerce site for a small start-up company.

  How are internet technologies affecting the structure

How are Internet technologies affecting the structure and work roles of modern organizations?

  Segregation of duties in the personal computing environment

Why is inadequate segregation of duties a problem in the personal computing environment?

  Social media strategy implementation and evaluation

Social media strategy implementation and evaluation

  Problems in the personal computing environment

What is the basic purpose behind segregation of duties a problem in the personal computing environment?

  Role of it/is in an organisation

Prepare a presentation on Information Systems and Organizational changes

  Perky pies

Information systems to adequately manage supply both up and down stream.

  Mark the equilibrium price and quantity

The demand schedule for computer chips.

  Visit and analyze the company-specific web-site

Visit and analyze the Company-specific web-site with respect to E-Commerce issues

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd