Question: in Java please with explanation FYI: - NO USE OF ARRAYS or any type of collection variables. Credit card validation Problem. A credit card number


in Java please with explanation
FYI: - NO USE OF ARRAYS or any type of collection variables. Credit card validation Problem. A credit card number must have between 13 and 16 digits. It must start with: 4 for visa cards 5 for master cards 37 for American express cards 6 for discover cards Let us determine whether a credit card number is valid or invalid. Credit card numbers are generated following this validity check, common as the modulus 10 check. Consider a credit card number 4388576018402626 Step 1: double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number. 4388576018402626 2*2=4 2*2 = 4 4*2=8 1*2=2 6*2=12 (1+2=3) 5*2=10 (1 +0=1) 8*2 = 16 (1+6 =7) 4* 2=8 Step 2: now add all the single digit numbers from step1 4 + 4 + 8 + 2+ 3+ 1 + 7 + 8 Step 3: add all digits in the odd places from right to left in the card number 6 + 6 + 0 + 8 + 0 + 7 + 8 +3 = 38 Step 4: sum the results from step 2 and step 3 37 + 38 = 75 Step 5: if the results from step 4 is divisible by 10, the card number is valid; otherwise, it is invalid. In this case, the card number is not valid - because 75 not divisible by 10. (Hint: modulus operator)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
