Write a programme on credit card number check

Assignment Help C/C++ Programming
Reference no: EM13164308

Credit Card Number Check. The last digit of a credit card number is the check digit, which protects against

transcription errors such as an error in a single digit or switching two digits. The following method is used to

verify actual credit card numbers but, for simplicity, we will describe it for numbers with 8 digits instead of 16:

 

  • 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.

  • 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 8. Adding all digits in these values yields: 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27.

  • Add the sums of the two preceding steps. If the last digit of the result is 0, the number is valid. In our

case, 23 + 27 = 50, so the number is valid.

Write a program that implements this algorithm. The user should supply an 8-digit number, and you should print

out whether the number is valid or not. HINTS: look at digitStripper.cpp and try to do this problem by hand for

the second example below before trying to write code.

Example runs (with user input indicated with bold italics):

Please enter 8-digit card number: 43589795

Card is valid.

Please enter 8-digit card number: 43589796

Card is not valid.

 

 

 

Reference no: EM13164308

Questions Cloud

Calculate the minimum number of grams of propane : calculate the minimum number of grams of propane that must be combusted to provide the energy necessary to convert 5.35 of ice at -21.5 to liquid water at 76.0.
What is the name to represent the actual shape : What is the name to represent the Electronic geometry of C2F2 and also how do you draw a diagram of the actual shape? What is the name to represent the actual shape?
Prepare adjusting entry to recognize bad debts : Show the December 31, 20XX balance sheet presentation of the Company's accounts receivable and related accounts for this assumption.
Calculate the mass of propylene glycol : Calculate the mass of propylene glycol that must be added to 0.500 kg of water to reduce the vapor pressure by 4.60 torr at 40 degrees celcius.
Write a programme on credit card number check : Credit Card Number Check. The last digit of a credit card number is the check digit, which protects againsttranscription errors such as an error in a single digit or switching two digits
How many vitamin c molecules are contained in the tablet : vitamin tablet contains 125 mg of vitamin C (C6H8O6). How many vitamin C molecules are contained in the tablet?
State volume of sodium acetate that you added to solution : For your cereal sample, you added the same volume of sodium acetate that you added to your standards and solution unknown. b) You forgot to add hydroxylamine hydrochloride when you prepared the standards
State a rubber balloon was inflated with helium gas : A rubber balloon was inflated with helium gas and floated in the air. The next day, the balloon was somewhat smaller and no longer floated.
Calculate w and delta e when one mole is vaporized : calculate w and delta e when one mole of a liquid is vaporized at its boiling point (80 degrees celscius) and 1.00 atm pressure. Delta H vaporization for the liquid is 30.7 kJ/mol at 80 degrees celscius.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Functions to compute stress and strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads P of 10,000 to 1,000,000 pounds.

  Create class integerset

Create class IntegerSet for which each object can hold integers in the range 0 through 100. Represent the set internally as a vector of bool values. Element a[i] is true if integer i is in the set. Element a[j] is false if integer j is not in the set..

  Attribute information about an array of floating point

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Writing a program that creates a linked list

Writing a program that creates a linked list from 100 randomly generated numbers and sorts the using a heap. One heap in ascending order and one heap in descending order. Then displays the original linked list and both sorted lists.

  The funtion should take as parameters

Write a function in c ++ that multiplies two functions. the funtion should take as parameters two fraction structures. Then, the function should multiply the two fractions and return the solution as a fraction structure.

  During the execution of the above code, how many instru

(a) During the execution of the above code, how many instructions are executed? (b) Assuming a standard unicycle machine (CPI = 1) running at 100 KHz, how long will the above code take to complete?

  Write a program for find greatest common divisor

Write code for a recursive implementation of Euclid's algorithm

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Dealerships are awarded the rebate

Dealerships are awarded the rebate on a quarter-by-quarter basis, only for quarters where their actual sales exceeded expected volumes for that quarter. Expected sales volumes for each quarter are as follows:

  Write a program using the rand() function

Write a program using the rand() function and a large array to find the standard deviation, variance and mean as well as the min and max values of the array.

  Write c program which has parent process and child process

Write a C program that has a parent process, a child process, and a grandchild process. The parent process should print its id and the square or 5.

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