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

Your program will ask the user to enter an ISBN number, and verify that the user

ID: 3546764 • Letter: Y

Question

Your program will ask the user to enter an ISBN number, and verify that the user entered 9 digits. If input was invalid, prompt the user to try again. Print the complete ISBN with check symbol. Note that the ISBN should be printed with a hyphen after the first and fourth digit, and before the check symbol.

Use a string method to properly format the ISBN before printing.

Use bool validateinput(string abc){ to validate the user input,

use char getCheckSum(string xyz){ for a loop to scan each digit of the ISBN
Allow the user to continue entering ISBNs until they indicate they want to quit.                       ==================Exp. Output=================================


Enter 9-digit ISBN: 123456789
Full ISBN with check symbol: 1-234-56789-X
Again [Y/N]?y
Enter 9-digit ISBN: hello
Enter 9-digit ISBN: 12345
Enter 9-digit ISBN: 098765432
Full ISBN with check symbol: 0-987-65432-2
Again [Y/N]?y


--------------------------------------------------------------------------------------------------------

# include <iostream>

# include <ctime>

# include < string>


validateinput(string abc)

char getCheckSum(string xyz)

int main()

{

int isbn;

bool isValid;


string isbn;

cout<< "Enter 9-digit ISBN: " ;

cin >> isbn;

     while( !isValid);

         cout << " Enter 9-digit ISBN: ";

         cin >> isbn;

Explanation / Answer

please rate - thanks

any questions --ask



# include <iostream>
# include <ctime>
# include <string>
using namespace std;
bool validateinput(string abc);
char getCheckSum(string xyz);
string format(string,char);
int main()
{char c;
string isbn;
do
{cout<< "Enter 9-digit ISBN: " ;
cin >> isbn;
while(!validateinput(isbn))
     {cout << "Enter 9-digit ISBN: ";
      cin >> isbn;
      }
c=getCheckSum(isbn);
cout<<"Full ISBN with check symbol: "<<format(isbn,c)<<endl;
cout<<"Again [Y/N]? ";
cin>>c;
cin.clear();
cin.ignore(80,' ');
}while(toupper(c)=='Y');
return 0;
}
bool validateinput(string abc)
{int i=0;
while(abc[i]!='')
     {if(!isdigit(abc[i]))
          return false;
      i++;
     }

if(i==9)
    return true;
return false;
}
char getCheckSum(string xyz)
{int i,weight=10,sum=0,n;
char c;
for(i=0;i<9;i++)
    { sum=sum+weight*(xyz[i]-'0');
    weight--;
     }
    n=sum%11;
    n=11-n;
    if(n==10)
         c='X';
    else
         c=n+'0';
return c;
}
string format(string isbn,char c)
{string out="";
int i;
for(i=0;i<9;i++)
    {out=out+isbn[i];
    if(i==0||i==3||i==8)
          out=out+'-';
     }
out=out+c;
out=out+'';
return out;
       
             
       }