2014 Old Spec

From TRCCompSci - AQA Computer Science
Revision as of 00:05, 29 November 2016 by Admin (talk | contribs) (Created page with "=Question 4= Create a folder/directory Question4 for your new program. The algorithm, represented using pseudo-code in Figure 5, and the variable table, Table 3, describe the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Question 4

Create a folder/directory Question4 for your new program. The algorithm, represented using pseudo-code in Figure 5, and the variable table, Table 3, describe the process of using a check digit to check if a value entered by the user is a valid 13 digit International Standard Book Number (ISBN).


Figure 5

FOR Count 1 TO 13 DO <br> OUTPUT "Please enter next digit of ISBN: "<br> INPUT ISBN[Count]<br> ENDFOR<br> CalculatedDigit = 0<br> Count = 1<br> WHILE Count < 13 DO<br> CalculatedDigit = CalculatedDigit + ISBN[Count]<br> Count = Count + 1<br> CalculatedDigit = CalculatedDigit + ISBN[Count] * 3<br> Count = Count + 1<br> ENDWHILE<br> WHILE CalculatedDigit >= 10 DO<br> CalculatedDigit = CalculatedDigit – 10<br> ENDWHILE<br> CalculatedDigit = 10 – CalculatedDigit<br> IF CalculatedDigit = 10<br> THEN CalculatedDigit = 0<br> ENDIF<br> IF CalculatedDigit = ISBN[13]<br> THEN OUTPUT "Valid ISBN"<br> ELSE OUTPUT "Invalid ISBN"<br> ENDIF<br>


Table 3

Identifier Data Type Purpose
ISBN Array[1..13] Of Integer Stores the 13 digit ISBN entered by the user – one digit is stored in each element of the array.
Count Integer Used to select a specific digit in the ISBN.
CalculatedDigit Integer Used to store the digit calculated from the first 12 digits of the ISBN. It is also used to store the intermediate results of the calculation.



What you need to do

  1. Write a program for the algorithm in Figure 5.
  2. Test the program by showing the result of entering the digits 9, 7, 8, 0, 0,

9, 9, 4, 1, 0, 6, 7, 6 (in that order).

  1. Test the program by showing the result of entering the digits 9, 7, 8, 1, 8,

5, 7, 0, 2, 8, 8, 9, 4 (in that order).

  1. Save the program in your new Question4 folder/directory.