The global trade item number (GTIN-8) barcode has seven digits and a check digit. This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the GTIN-8. DIV (X, Y), finds the number of divides in division for example DIV (23,10) is 2. MOD (X, Y), finds the remainder in division for example MOD (23,10) is 3. ``` FOR Count ← 1 TO 7 INPUT Number Digit(Count) ← Number NEXT Sum ← (Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6) IF MOD(Sum,10) <> 0 THEN Digit(8) ← DIV(Sum,10)*10 + 10 – Sum ELSE Digit(8) ← 0 ENDIF OUTPUT "GTIN-8" FOR Count ← 1 TO 8 OUTPUT Digit(Count) NEXT ```
- (a)Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4 | Digit(1) | Digit(2) | Digit(3) | Digit(4) | Digit(5) | Digit(6) | Digit(7) | Digit(8) | Sum | OUTPUT | |----------|----------|----------|----------|----------|----------|----------|----------|-----|----------| | 5 | 7 | 0 | 1 | 2 | 3 | 4 | | 44 | GTIN-8 | | | | | | | | | | | 57012346 | Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1 | Digit(1) | Digit(2) | Digit(3) | Digit(4) | Digit(5) | Digit(6) | Digit(7) | Digit(8) | Sum | OUTPUT | |----------|----------|----------|----------|----------|----------|----------|----------|-----|----------| | 4 | 3 | 1 | 0 | 2 | 3 | 1 | | 30 | GTIN-8 | | | | | | | | | | | 43102310 |[5]
- (b)Explain how you would change the algorithm to input eight digits (seven digits and the check digit) and output if the check digit entered is correct or not.[3]
Mark scheme
Marking points from the official mark scheme (May/June 2018). The mark or mark type is shown in brackets.
- [1] (a) One mark for data entry – both sets of digits 1-7
- [1] (a) One mark for both Digit(8)
- [1] (a) One mark for each Sum (max Two)
- [1] (a) One mark for both OUTPUT
- [1] (b) Change first loop to 8 iterations
- [1] (b) Check that the input Digit (8) is equal to the calculated Digit (8)...
- [1] (b) ...if equal output check digit correct
- [1] (b) ...otherwise output check digit incorrect
- [1] (b) OR Change first loop to 8 iterations
- [1] (b) OR Put all 8 digits through the algorithm to calculate Sum
- [1] (b) OR ...if MOD(Sum,10) is equal to zero, check digit correct
- [1] (b) OR ...otherwise output check digit incorrect
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →