Assignment 4

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Assignment 4 as PDF for free.

More details

  • Words: 432
  • Pages:
CIS*1500 Introduction to Programming Fall 2009 ASSIGNMENT 4 Weighting: 8% Due date: November 24, 2009 Calculating 13-digit ISBN Checksums

The International Standard Book Number ( ISBN ) is a code that uniquely specifies a book. The number is either 13 or 10 (before 1 January 2007) digits long, and consists of four or five parts: 1. 2. 3. 4. 5.

if 13-digit ISBN, a GS1 Prefix, either 978 or 979 the country of origin or language area code the publisher the item number a checksum character or check digit.

For the 13-digit ISBN, the rightmost digit is a checksum digit which can be uniquely determined from the other 9 digits using the equation:

where d denotes the ith digit from the right. For example, the calculation for the 10digit ISBN whose first 12 digits are 978-1-55285-954-4 is:









= 9×1 + 7×3 + 8×1 + 1×3 + 5×1 + 5×3 + 2×1 + 8×3 + 5×1 + 9×3 + 5×1 + 4×3 = 9 + 21 + 8 + 3 + 5 +15 +2 +24 +5 + 27 + 5 + 12 = 136 = 136 mod 10 = 6 = 10 -6 = 4

Programming Task Using the information given, write a program that takes a 13-digit ISBN number as input, computes the checksum, and interprets whether the ISBN number is valid or not. Create the following three functions (apart from the main function) in your program:

read_ISBN

-Read in the 13-digit ISBN, and return it to main.







is_Valid













check_Sum

-Take ISBN as input and calculate the checksum,



returning its value.

-Take the ISBN as input, and check its validity, outputting an appropriate message to the user. This function calls the function check_Sum.

The main function should run the function read_ISBN, followed by the function is_Valid. The first challenge with this assignment is how to input the data. There are various possibilities, each will have its own benefits and drawbacks. You should also validate that the ISBN entered has the correct number of digits before proceeding with checking its validity.

Testing Data Your program should work properly on the following data: 9780757541360 9781593271190 9780471754793 978047174794 9780789315922 9780231133135

valid valid not valid, incorrect checksum not valid, too short valid valid

Grading Criteria This assignment is graded using Rubric B. Please refer to the document “Assignment Guidelines” for detailed information on the grading criteria. NOTE: If your program does not compile, the assignment receives an automatic grade of zero.

Academic Misconduct This course uses software to systematically inspect all solutions for possible plagiarism. Please refer to the Academic Integrity policy of the course outline.

Related Documents

Assignment 4
May 2020 12
Assignment 4
June 2020 9
Assignment 4
May 2020 9
Assignment#4
November 2019 20
Assignment 4
October 2019 24
Assignment 4
November 2019 13