Use 16 digit credit card numbers that contain 15 digits an 1 check digit. The format of the card number consists of the 15 digits followed by the check digit. The check digit is computed by adding the 15 digits and then determining what digit (0-9) would need to be added to that so the result is evenly divisible by 10. So you would need to first add up the first 15 digits and then find out which number you would have to add to make the end result divisible by 10. In the example, the first 15 digits added up equal 75 and the you would need to add 5 to give the end result 80 and 80 is evenly divisible by 10.
For example,
8546 9234 8771 452X
(X is the check digit)
Add up each digit:
8+5+4+6+9+2+3+4+8+7+7+1+4+2+5= 75
For this to be evenly divisible by 10, you would need to add 5 to make the total result equal 80. So the check digit or X would equal 5.
For this program you need to write two functions. The First function verifies that a credit card number is valid. Ignore spaces in the credit card number, but other non-numeric characters will result in the number being invalid as will fewer/more than 16 digits. Write a Second function that randomly generates a VALID card Number
Finally, write a main function that creates 10 randomly generated numbers and validates them. Next, allow the user to enter card numbers and have the program tell the user whether their card number is valid or not.
I am so lost please help