An International Standard Book Number (ISBN) is a unique number assigned to each book. ISBN-10 has ten digits in 4 parts which the last digit is check digit. The check digit is base eleven, and can be 0-9 or X (instead of 10). To compute a missing check digit, each digit should be multiplied by its position in the number (counting from the right). Then, the sum of these products should
be divided by 11 to find the remainder. Finally, the check digit can be found by subtracting the remainder from 11.
For example, take the ISBN 0-201-53082-?:
- First calculate sum of products: 010 + 29 + 08 + 17 + 56 + 35 + 04 +
83 + 22 = 98
- Remainder upon dividing by 11 is 10.
- Remainder is subtracted from 11.
- Check digit is 1.
For more information, watch the following Youtube video about finding the missing check digit of an ISBN number https://www.youtube.com/watch?v=5qcrDnJg-98
Part A: RAPTOR Exercise
- Start RAPTOR and create a flowchart that asks the user to enter the first 9 digits of an ISBN-10, and displays the corresponding check digit.
- Run the flowchart with different numbers.
- Save the flowchart to a file named isbn.rap in the working directory on the PC you are using.
- Demonstrate the isbn.rap file to GA/TAs and run with different input values.
Part B: C Programming Exercise
- Implement the algorithm as represented by isbn.rap, and write an equivalent C program that accomplishes what the flowchart does. The program, however, is allowed to call the scanf() function only once. A sample interaction is shown below:
Enter the first nine digits of ISBN: 020153082 Check digit: 1
- Save your program to a file named isbn.c in the working directory on the PC you are using.
- Demonstrate the isbn.c file to GA/TAs and run with different input values.
- Hint: To read single digits, well use scanf with the %1d conversion specification.
EVALUATION:
You need to show your GA/TA the complete programs at the end of this lab, or at the beginning of your next lab. The marks you will receive for this lab are made of two parts: Lab work marks 10 and attendance marks 5. Total 15 marks.
Lab Work Mark: Your C code will be evaluated based on your solutions for the problems based on the following scheme:
- Does the code run and meet specifications?
- Is input adequate and input data type properly validated?
- Is processing adequate?
- Is output correct and adequate?
- Is the code compliable?
- Is the code run properly?
- Is the code properly commented?
- Is the program title, programmers first and last name, and the date posted at the top in a multi-line comment?
- Is each significant step of the program properly commented?
- Are comments added to clarify details?
- Are comments clear, accurate, neatly formatted, and have no misspellings?
- Is the code properly formatted?
- Are blocks of code indented according to their parent-child relationship?
- Do curly braces line up vertically?
- Is there an empty line between significant steps (blocks) of the program?
- Is the width of the code contained within a reasonable limit so that minimal horizontal scrolling is required (with 800 x 600 monitor resolution), and there is minimal line-wrapping when printed?
- Is camel-case notation used for variable, e.g. employeeLastName?
IMPORTANT:
ASK QUESTIONS IF YOU GET STUCK, BUT DO YOUR OWN CODE. ANY CODE SUSPECTED TO BE SIMILAR TO ANOTHER SUBMISSION WILL CAUSE BOTH SUBMISSIONS TO RECEIVE A ZERO MARK ON ALL LABS AND BE REPORTED FOR PLAGIARISM.
Reviews
There are no reviews yet.