Credit Card Number CheckThe last digit of a credit card number is the check digitwhich 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 4358 9795, 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. If it is not valid , you should print the value of the check digit that would make it valid .

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question
100%

Credit Card Number CheckThe last digit of a credit card number is the check digitwhich 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 4358 9795, 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. If it is not valid , you should print the value of the check digit that would make it valid .

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage