Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that performs Credit Card Number Check. Your program should ( Note that the blue part represents the user input, and 4
Write a program that performs Credit Card Number Check. Your program should Note that the blue part represents the user input, and represents the return key from
repeatedly ask the user to input an digit number to check if it is valid, until the user
enters to quit. Please note that for simplicity, now you can assume the user will
always enter digit numbers to check except for quitting the program with In the
coming week, we will learn how to handle the user input validation Please note that this
Lab assignment is from the Programming Project of the ZyBook.
Your program will implement the following algorithm:
The last digit of a credit card number is the check digit, which protects against
transactions errors such as an error in a single digit or switching two digits. The following
method is for numbers with digits:
Starting from the rightmost digit, form the sum of every other digit. For example,
if the credit card number is Then you form the sum
Double each of the digits, which 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 nexttolast one, yields
Adding all digits in these values yields
Add the sums of the two preceding steps. If the last digit of the result is the
number is valid. In our case, so the number is valid.
After the user supplies an digit number, your program should implement the above
algorithm, then print out whether the number is a valid credit card number or not. If it is
not valid, you should print out the value of the check digit that would make the number
valid.
The following show some examples of running your program:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started