Here is the problem And here is my code And the ouput looks
Here is the problem
And here is my code
And the ouput looks wried and I dont know why.
And I have no idea about how to make the program aksing user if he wants to enter another number and quit if not?
(75 pts) Problem Statement (Modified from Princeton\'s CS1: The International Standard Book Number (ISBN) is a 10 digit or 13 digit code that uniquely specifies a book. The rightmost digit is a checksum digit which can be uniquely determined from the other 9 or 12 digits A 10 digit ISBN has the condition that d1 + 2d2 + 3ds + … + 10d10 must be a multiple of 11 (here di denotes the ith digit from the right). The checksum digit d can be any value from 0 to 10: the ISBN convention is to use the value X to denote 10. Example: the checksum digit corresponding to 020131452 is 5 since is the only value of d between 0 and 10 for which d1 2*2 +3*5+4*4 51 6*3 7*1+8*09*2 10\"0 is a multiple of 11 A 13 digit ISBN has the condition that d1 + 3d2+ d3 + 3da +… + 3d12+ d13 must be a multiple of 10 (here di denotes the ith digit from the right) and begin with 978 (or 979) The checksum digit d1 can be any value from 0 to 9. Example: the checksum digit corresponding to 978084939640 is 3 since is the only value of di between 0 and 9 for which di 3*0 1*4 + 3*61*9 3*31*93*41*83*0+ 1*83*7 1*9 is a multiple of 10 Write a program that asks the user whether he/she wants to compute the checksum for a 10 digit or 13 digit ISBN. Read the corresponding 9-digit or 12-digit integer from the user and compute the checksum.\" Print the 10-digit or 13-digit ISBN number back to the user. It\'s ok if you don\'t print any leading Os. Ask the user if he/she wants to enter another number, and quit if not. *You may need to use the chart on the ISBN link!Solution
You can use do while loop to solve above problem:
Code:
#include <iostream>
#include <map>
#include<list>
#include<vector>
#include<algorithm>
using namespace std;
int main ()
{
int digit;
int ISBN_10;
int ISBN_13;
int d_10;
int d_13;
int ch;
do
{
cout<<\"You want to compute the checksum for a 10 digit or 13 digit ISBN?\"<<endl;
cin>>digit;
if(digit==10)
{
int a,b,c,d,e,f,g,h,i;
a=0;
cout<<\"PLS enter the checksum in 9 bits!\"<<endl;
cin>>b,c,d,e,f,g,h,i;
d_10=11-(10*a+ 9*b +8*c+7*d+6*e+5*f+4*g + 3*h +2*i)%11;
cout<<\"The 10 bits ISBN number will be\"<<a<<\"-\"<<b<<\" \"<<c<<\" \"<<d<<\" \"<<e<<\"-\"<<f<<\" \"<<g<<\" \"<<h<<\" \"<<i<<\"-\"<<d_10<<endl;
}
else
{
int j,k,l,m,n,o,p,q,r,s,t,u;
cout<<\"PLS enter the checksum in 12 bits!\"<<endl;
cin>>j,k,l,m,n,o,p,q,r,s,t,u;
d_13 = 10-(j+3*k + l+3*m+n+3*o+p+3*q+r+3*s+t+3*u)%10;
cout<<\"The 13 bits ISBN number will be\"<<j<<k<<l<<\"-\"<<m<<n<<o<<p<<q<<\"-\"<<r<<s<<t<<u<<\"-\"<<d_13<<endl;
}
cout<<\"Do you want to enter another number(PRESS 1 for Yes or 0 for NO)\";
cin>>ch;
}while(ch==1);
return 0;
}

