Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1) Books are assigned identification numbers called ISBN s. Each ISBN is a ten

ID: 3549656 • Letter: #

Question




(1) Books are assigned identification numbers called ISBNs. Each ISBN is a ten - digit number such as 1 - 55953 - 407 - 9 . The final digit is called the check digit which is determined on the basis of modular arithmetic. The final ( check ) digit is obtained as follows: start at the left and multiply the first nine digits of the ISBN number by 10 ,

9 , 8 , 7 , 6 , 5 , 4 , 3 and 2 , respectively. Then add these products. The check digit is the smallest number that must be added to the result to arrive at a multiple of 11 .


Write a program that finds the check digit for the following ISBN : 0 - 13 - 089367 - __


Explanation / Answer

please rate - thanks



#include <iostream>
#include <string>
using namespace std;
int checkDigit(string);
int main()
{string isbn;
cout<<"enter the first 9 digits of the isbn: ";
cin >> isbn; //read a ISBN number
cout<<"The ISBN is: "<<isbn<<'-'<<checkDigit(isbn)<<endl;
system("pause");
return 0;
}
int checkDigit(string isbn)
{ int i,sum=0,digit;
for(i=0;i<9;i++)
    sum=sum+(isbn[i]-48)*(10-i);
sum%=11;
digit=11-sum;
cout<<"The check digit is: "<<digit<<endl<<endl;
return digit;
}