Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Advanced level school Python programming. need helps 2 Every published book has an International Standard Book Number (ISBN). This ISBN is a 9-digit number plus
Advanced level school Python programming. need helps
2 Every published book has an International Standard Book Number (ISBN). This ISBN is a 9-digit number plus a check digit which is calculated and added to the end of the number. A weighted-modulus method is used to calculate the check digit. This method uses a weighted modulus 11 . If the check digit is calculated as 10 , it is replaced with the character ' X '. Where the check digit is calculated as 11 , it will be replaced with 0 . Task 2.1 Study the identifier table and the incomplete recursive algorithm on the opposite page. The missing lines in the algorithm are labelled A,B and C. Write the three missing lines of code. Label each as A,B or C. FUNCTION CalCheckDigit(Number AS STRING, Total AS INTEGER) RETURNS STRING IF LENGTH (Number) > I THEN Digit INTEGER (LEFT (Number, 1)) Total Total +( Digit * ( LENGTH ( Number )+1)) NewNumber RIGHT (Number, LENGTH (Number) -1 ) CheckDigit A . . . . . . . . . . . . . . . . . . . ELSE Digit INTEGER (LEFT (Number, 1)) Total Total + (Digit * (LENGTH (Number) +1)) CalcModulus Total MOD 11 CheckValue 11 - CalcModulus IF CheckValue =11 THEN RETURN STRING(0) ELSE IF CheckValue =10 THEN ELSE RETURN STRING (CheckValue) ENDIF ENDIF ENDIF IF LENGTH (Number) =9 THEN RETURN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ELSE RETURN CheckDigit; ENDIF END FUNCTION // Calculate ISBN, an example of how the function is called. // Second parameter is always 0 . ISBN = CalCheckDigit("184146208",0) Task 2.2 Write a program to implement the ISBN program using the CalCheckDigit function. The program will: - read the entire contents of the file ISBNPRE. TXT (seven 9-digit ISBNs without check digits) into an appropriate data structure - use the function CalCheckDigit to calculate the result (ISBN with check digit) for each entry in the file - write each result (ISBN with check digit) to the screenStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started