Bar code check digit

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Bar code check digit

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which digit of an EAN-13 bar code number is the check digit?
A The first digit
B The last (13th) digit
2. What does the scanner do with the check digit?
A Uses it to look up the price of the item
B Recalculates it from the other digits and compares it
3. Which weights does EAN-13 use when calculating its check digit?
A Alternating 1 and 3, the same as ISBN-13
B Counting down from 13 to 2
4. The scanner recalculates the check digit and it does not match the last digit. What happens?
A It beeps again or asks for a rescan
B It adds the item to the till using the closest matching code
5. In an EAN-13 calculation, what weight does the second digit get?
A 3
B 1

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1weights: 1 3 1 3 1 3 1 3 1 3 1 3 ATurns the weighted total into the check digit. If the total ends in 0, the check digit is 0.
2(10 - (total MOD 10)) MOD 10 BThe first 12 digits of an EAN-13 bar code are multiplied by alternating weights of 1 and 3, the same pattern as ISBN-13.
3The scanner recalculates the check digit from the first 12 digits and compares it with the 13th digit it read. CA match means the read passed the check, so the item should be accepted. The scanner should only beep and ask for a rescan when the digits do not match.
4If the recalculated check digit does not match, the scanner rejects the misread and beeps for the item to be scanned again. DIF calculated = digit13 THEN accept
5weights: 3 3 3 3 3 3 3 3 3 3 3 3 EEAN-13 does not use the weight 3 for every digit. The weights alternate 1, 3, 1, 3 and so on, starting with 1.
6IF calculated = digit13 THEN rescan FIF calculated ≠ digit13 THEN beep and rescan

Definitions

check digit

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
check ← (10 - (total ___ 10)) MOD 10
2.
IF position MOD 2 = 0 THEN weight ← _
3.
IF calculated __ lastDigit THEN OUTPUT "Scan again" ENDIF
4.
first12 ← LEFT(code, 12) lastDigit ← MID(code, __, 1)
5.
REPEAT INPUT code _____ checkOK = TRUE

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A total ← weighted sum
B r ← total MOD 10
C check ← (10 - r) MOD 11
D PRINT check
Question 2
A FOR i ← 1 TO 12
B IF i MOD 2 = 1 THEN w ← 3
C ELSE w ← 3
D total ← total + w * d[i]
E NEXT i
Question 3
A code ← SCAN()
B calc ← CALC(code)
C IF calc = RIGHT(code, 1) THEN
D PRINT "Accepted"
Question 4
A check ← RIGHT(code, 1)
B calc ← CALC(LEFT(code, 12))
C IF calc <> check THEN
D OUTPUT "Accepted"
E ENDIF
Question 5
A total ← 1
B FOR i ← 1 TO 12
C total ← total + w * d[i]
D NEXT i

Answer Key

Bar code check digit
Section A: Quick Questions
Q1
B — The last (13th) digit
Q2
B — Recalculates it from the other digits and compares it
Q3
A — Alternating 1 and 3, the same as ISBN-13
Q4
A — It beeps again or asks for a rescan
Q5
A — 3
Section B: Match the Pairs
Q1
weights: 1 3 1 3 1 3 1 3 1 3 1 3 → The first 12 digits of an EAN-13 bar code are multiplied by alternating weights of 1 and 3, the same pattern as ISBN-13.
Q2
(10 - (total MOD 10)) MOD 10 → Turns the weighted total into the check digit. If the total ends in 0, the check digit is 0.
Q3
The scanner recalculates the check digit from the first 12 digits and compares it with the 13th digit it read. → IF calculated = digit13 THEN accept
Q4
If the recalculated check digit does not match, the scanner rejects the misread and beeps for the item to be scanned again. → IF calculated ≠ digit13 THEN beep and rescan
Q5
weights: 3 3 3 3 3 3 3 3 3 3 3 3 → EAN-13 does not use the weight 3 for every digit. The weights alternate 1, 3, 1, 3 and so on, starting with 1.
Q6
IF calculated = digit13 THEN rescan → A match means the read passed the check, so the item should be accepted. The scanner should only beep and ask for a rescan when the digits do not match.
Section C: Definitions
Q1
check digit — The last digit of a bar code number, worked out from the other digits. The scanner recalculates it and rejects a misread if the digits do not match, so the item must be scanned again.
Section D: Fill in the Blanks
Q1
check ← (10 - (total MOD 10)) MOD 10
Q2
IF position MOD 2 = 0 THEN weight ← 3
Q3
IF calculated <> lastDigit THEN OUTPUT "Scan again" ENDIF
Q4
first12 ← LEFT(code, 12) lastDigit ← MID(code, 13, 1)
Q5
REPEAT INPUT code UNTIL checkOK = TRUE
Section E: Spot the Error
Q1
C — EAN-13 bar codes use modulus 10, not 11. The check digit is (10 - r) MOD 10. Modulus 11 is used for other check digit schemes.
Q2
B — EAN-13 uses weights 1 and 3 alternately, starting with 1 for the first digit. Odd positions get weight 1 and even positions get weight 3, so the line should set w ← 1.
Q3
B — The scanner must recalculate the check digit from the first 12 digits only. Passing the whole code includes the check digit itself. It should be CALC(LEFT(code, 12)).
Q4
D — When the recalculated digit does not match the check digit, the scan is rejected. The scanner should beep and ask for a rescan, not accept the item.
Q5
A — The running total must start at 0. Starting at 1 adds an extra amount to the weighted sum and gives the wrong check digit.