Starting from the rightmost digit

Assignment Help Basic Computer Science
Reference no: EM131709594

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: EM131709594

Questions Cloud

First character of the current string : If the current string's last character is I, then add U onto the end of the current string.
Discuss the potential legal and ethical issues arising : Identify and discuss the potential legal and ethical issues arising from the following fact pattern:
Regression model to predict a firm pension funding : Results of a study reported in Financial Analysts Journal include a simple linear regression analysis of firms' pension funding (Y ) versus profitability (X).
Describe an effective retention process : Create a slide presentation to serve as a learning aid for managers. Incorporate both text and images.Describe an effective retention process.
Starting from the rightmost digit : 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
Some designs of products and services are inherently bad : Some designs of products and services are inherently bad. Read about them at the bad designs web site.
Describe what parts of gmp were violated in the given case : Type "Warning Letters" in the search engine. Write a 400 word paper summarizing case and then describe what parts of GMP were violated in that case.
Advise the liquidator on any breaches of the duty : LAWS3100 Corporations Law Questions - Advise the liquidator on any breaches of the duty(ies) to avoid insolvent trading in the Corporations Act 2001 (Cth)
Best quantity to balance ordering cost and carrying cost : Use the EOQ formula to calculate the best quantity to balance ordering cost and carrying cost.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Develop a program that will input the miles driven

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven.

  Catering web design

Using the graphics provided to develop the first five pages of a prototype Web site for a catering company. The site should include the following elements:

  How the pages hold style continuity in grid system

Export the finished article as PDF format AND also give me the original indesign file, and the fonts you used.

  Create a home page with navigation bar

Create a home page with navigation bar

  Different possible distributions

A student wishes to allocate her study time among a mathematics, english, and German. Suppose that she has a total of 18 hours of study time a week, and decides to spend 4 times as much time on mathematics as she spends on english. How could she d..

  Design an algorithm that accepts as input a decimal number

Design an algorithm that accepts as input a decimal number and converts it to the binary-coded decimal (bcd) representation. In the bcd scheme each digit is represented by a 4-bit binary code.

  Social media platform such as pinterest

What are some of the information systems used in a social media platform such as Pinterest?

  Plot the free stream velocity of the hydrogen gas

Reconsider Problem. Using the EES (or other) software, evaluate the effect of glycerin mass flow rate on the free-stream velocity of the hydrogen gas.

  What happens when an instruction writes to va page 200

What happens when an instruction writes to VA page 30? When would a software managed TLB be faster than a hardware managed TLB?

  Structures, arrays and strings

In this exercise you must create a program that deals with material information so as to calculate the supply need for raw materials and to organize( program ) the production of intermediate and final products in order to satisfy some orders. The ..

  Create a linked list version of the indicated algorithm

Implement the addToSortedList() function for use with the linked list version of the insertion sort algorithm.

  Write a matlab program that uses the switch structure

To start a weight W moving on a horizontal surface, you must push with a force F, where F = μW. Write a MATLAB program that uses the switch structure to compute the force F. The program should accept as input the value of W and the type of materia..

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