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

  Write c program that forks two child processes

Write a C program that forks two child processes. The parent process will print all prime numbers up to 229, the first child process will print the first 50 Fibonacci numbers.

  Write program to declare the array of type float

Write down the c++ program which declares the array of 50 components of type float. Initialize array so that first 25 components are equal to square of the index variable.

  Write a program that asks the user to enter the names of 3

Write a program that asks the user to enter the names of three salesmen. The program should thenaccept the sales produced for salesman for each quarter of the year. Display the name, and the totalsales amount, of each salesman.

  File system with login authentication

Implement a simple file system with login authentication and access control - Construct a hash/salt/shadow based user/password creation system.

  Program to print out invalid number to character

The integer must contain 3 distinct non-zero number, or the program will print out invalid number.it should print out invalid query.

  Implement circular linked list in c program

implement circular linked list in c program in the best possible easiest way.

  Program to store lists of names and ages in parallel arrays

Write a C++ program that stores lists of names (the last name first) and ages in parallel arrays and sorts the names into alphabetical order keeping the ages with the correct names.

  Techniques for information hiding and encapsulation

What techniques did you utilize for information hiding and encapsulation? Are there any improvements you would make? If so, what would they be?

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  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.

  Create a website that would allow users to enter and submit

Create a Website that would allow users to enter and submit survey

  Create huffman codes

Write a C++ program to create Huffman codes. Program input is a file called freq.txt (make up your own file for testing) that contains data on the characters in some cleartext file in the form of each character's non-zero frequency of occurrence i..

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