Say theyres an entered number of 14, that can be stored in a substring, and it registers as two places right? (one for 1, one for 4). now how can i make a program decide, using if statements, whether the inputted value was two or 1 places? I need to write a program to answer this:
6. The last digit of a credit card number is the check digit, which protects against transcriptions 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 16:
o Starting from the right most digit, form the sum of every other digit. For example, if the credit card number 4358 8795, then you form the sum 5+7+8+3=23.
o Double each of the digits that were not used in the preceding step. Add all digits of the resulting numbers. For example, with the number given abov, 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 = 27.
o Add the sum of the two preceding steps. If the last digit of the result is 0, 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 out the value of the check digit that would make the number valid.