Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A check digit (aka checksum digit) is added to a number, such asbook ISBN number or bank routing number, to verify the correctnessof the number.

A check digit (aka checksum digit) is added to a number, such asbook ISBN number or bank routing number, to verify the correctnessof the number. The check digit is usually added as the last digitin the number. A common usage of a check digit is to detect errorsmade while entering the number into a system. For this assignment,you will write a C++ program to generate check digits for ISBN-13numbers. The ISBN-13 is a standard, introduced in 2007, foridentifying books. It uses 13 digits d0d1d2d3d4d5d6d7d8d9d10d11d12.The last digit d12 (i.e., the 13th digit) is check digit that iscalculated from the other digits using the following formula: 10 -(d0 + d1 * 3 + d2 + d3 * 3 + d4 + d5 * 3 + d6 + d7 * 3 + d8 + d9 *3 + d10 + d11 * 3) % 10 If the checksum is 10, replace it with 0.Your code must have a function that accepts a string parameter ofthe first 12-digits in an ISBN-13 number and returns the checksumdigit (i.e., the 13th digit). You may use other functions if youlike. For example, a helpful function takes a character containinga digit as parameter and returns that digit as an integer, whichyou can define as follows: int toDigit(char ch){ return ch - '0';// ascii values are subtracted } The program must read input from afile, named isbn.txt, that is located in the same folder as theprogram. Each line on the file contains the first 12-digits of avalid ISBN-13 number. The program outputs to the computer's screenthe checksum digit for each number in the file. For example, usingthe following input file: 978013213079 978032156384978007063546 978032126817 978145169885978013213080 978160469555 978032133487978147926720 your program should produce the followingoutput: 0 2 3 4 5 6 7 9 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Students also viewed these Programming questions

Question

6. Explain the concept of image transfer in terms of sponsorship.

Answered: 1 week ago