Validate the credit card number

Assignment Help Basic Computer Science
Reference no: EM131713029

The last digit of a credit card number is the "check digit" that protects against errors. For simplicity we will use credit cards with just 8 digits instead of 16.  The user will input the 8 digit credit card number as a string and you will convert it to a list using the list() function. You need to validate the length of the string entered. If it is less than or greater than 8 characters, ask for another string. Validate the credit card number that you receive according to the following rules:

  1. Starting from the rightmost digit, form the sum of every other digit - for example, if the credit card number is 43589795 then you form the sum 5 + 7 + 8 + 3 = 23.
  2. Double each of the digits that were not included in the preceding step. Add all digits of the resulting numbers. For example, with the number given above, doubling the digits starting with the next-to-last one, yields 18 18 10 and 8. Adding all the digits in these values results 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27.
  3. Add the sums of the two preceding steps. If the last digit of the result is 0, the number is valid. In the example, 23+ 27 = 50 so the number is valid.

Reference no: EM131713029

Questions Cloud

What feature do you find most valuable : Discuss how you have used Microsoft Word, what feature do you find most valuable. Explain your answer.
Discuss heart disease is the number one cause of death : Suppose the organization you work for has conducted an epidemiological assessment for Community A and found that heart disease is the number one cause of death
Briefly summarize your findings of the atmosphere : Briefly summarize your findings of the atmosphere, hydrosphere, etc. This information should fit on 3-4 slides at most.
Rest of the string is denoted by r : If the first character of the current string is M, and the rest of the string is denoted by R (so the current string looks like MR) then the new string is MRR.
Validate the credit card number : If it is less than or greater than 8 characters, ask for another string. Validate the credit card number that you receive according to the following rules:
Discuss hispanics and asian americans : Discuss special issues in counseling the following ethnic groups: Hispanics and Asian Americans
Elaborate on the components of the counseling profession : Elaborate on the components of the counseling profession, professional associations and counselor credentialing
Count the total number of households : Use any considerations you like to divide Stephens County into strata. Your stratification should divide Lockhart City into approximately five strata.
Telecommunication applications and services : Discuss the following telecommunication applications and services: (i) Caller ID, (ii) Automatic Call Distribution, (iii) Automated Attendance

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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