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

  Binary tree, print right view of it

Given a Binary Tree, print Right view of it. Right view of a Binary Tree is set of nodes visible when tree is visited from Right side.

  Write program to calculate net pay for factory worker

Write and run a program in C++ that calculates the net pay for a factory worker. The program prompts the user for skill level and hours worked, as well as appropriate insurance and retirement options for the employee's skill.

  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.

  Write a program the contains an array of 1000 elements name

Write a function named equals() that accepts two char arrays and return true if both arrays have the same characters in the same order. The function should return false otherwise. Write a simple main() function to test your function.

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  Program that asks the user to enter the number of miles

Write a C - program that asks the user to enter the number of miles traveled and the number of gallons of gasoline consumed. It should then calculate and display the miles-per-gallon value. Confine your output to 1 decimal place.

  Perform operations on arrays

Perform operations on arrays execute tests and repetitions

  Write a program that skip s leading whitespace character

a) Write a program that skip s leading whitespace character s in each line of the pro vided data file CPPHumor .txt . Save the results in a new file

  Implement database having array of pointers

One way to implement this database is to have an array of pointers pointing to Employee objects. You will obviously require a function named Calculate_salary() which will be different for each employee class. Write code in c++

  Assign passed value to function to return value

Assign passed value to this member and another function to return value. Your main should read the integer from an input data file, and write the output to the output data file.

  Write an lc-3 machine language program

Write an LC-3 machine language program starting at location x3000 which divides the number in memory location x4000 by the number in memory location x4001 and stores the quotient at x5000 and the remainder at x5001.

  Write a program to convert between rectangular

Write a program to convert between rectangular and cylindrical coordinates, based upon user input. For example, if the user wants to convert cylindrical to rectangular coordinates, the user would input r, ?, z values and the program would output x, y..

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