sfolax6776

14 hours agoA. Introduction A valid credit card number will yield a result divisible by 10 when you:
Form the sum of all digits. Add to that sum every second digit, starting with the second digit from the right. Then add the number of digits in the second step that are greater than four. The result should be divisible by 10.
For example, consider the number 4 0 1 2 8 8 8 8 8 8 8 8 1 8 8 1. The sum of all digits is 89. The sum of the bold digits is 46. There are five bold digits larger than four, so the result is 89+46+5=140. 140 is divisible by 10 so the card number is valid. B. Write your code to check if a credit card number is valid or not according to the rules above. You need to verify if the input is a 12-digit number.

Print “Please input a string of the format ‘FIRSTNAME LASTNAME SCORE SCORE SCORE… -1’”

Allow for input of a string named input

While input is not equal to “END”

If the substring of input between input length-3 and input length is not “ -1”

Print “error”

Exit program

Create int a = 0

Create int b = 0

For (input length)

If the character at a is not “ ”

a++

Else

a++

b++

If b < 3

Print “error”

Exit program

//Checks if there are 3 spaces, the minimum required for this format

Create int i = 0

While the character at i is “ ”

i++

//there is a space at i

Create int j = i+1

While the character at j is not “ ”

j++

Create int k = j+1

Create int l = 0

Create int m = 0

While the substring of input between k and (input length) is not “-1”

If the character at k is not “ ”

If the character at k is not an integer

Print “error”

Exit program

k++

l++

Else

If l > 3

Print “error”

Exit program

Else if the substring of input between k-3 and k converted to an integer is greater than 100

Print “error”

Exit program

m = m + convert substring of input between k-l and k to integer

k++

l = 0

Print (substring of input between 0 and i)+ “ ” +(substring of input between i+1 and j) “‘s total score is ” + m