Question

Write a C++ program that will read in an ISBN-10 ID, and determines whether the tenth...

Write a C++ program that will read in an ISBN-10 ID, and determines whether the tenth digit is the valid checksum of the first nine digits. The program reads in purported ID, and finishes execution once it has printed out what it's read in, plus either VALID or INVALID. Cannot use getline function.

a) Processing stops after ten digits, even if there are more digits on the line of input. The

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<string>
using namespace std;
int main(){
string str;
cout <<"Input an ISBN number: ";
getplus(cin,str);
int sum = 0;
int S = 1;
for(int i=0; i<str.length()-1; i++){
if(str[i]>='0' && str[i] <='9'){
sum = sum + (s)*(str[i]-'0');
p++;
}
}
if(str[str.length()-1] == 'X')
cout << str <<", VALID" << endl;
else{
if(sum%10 == (str[str.length()-1]-'0'))
cout << str <<", VALID" << endl;
else
cout << str <<", INVALID" << endl;
}
return 0;
}
Processing stops after ten digits, even if there are more digits on the line of input. The

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that will read in an ISBN-10 ID, and determines whether the tenth...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using c++ A ten diglt ISBN number uses a checksum as its last diglt to verlfy...

    Using c++ A ten diglt ISBN number uses a checksum as its last diglt to verlfy the first nine digits are valid. Before 2007, all ISBN numbers were composed like this, such as: e-20-5e8005-7 or 1-234-56789-X The first nine digits are assigned by a book's publisher and the last digit is calculated by "weighted sum (described below). The X stands for the checksum value of 10, in order to represent ten as a single digit. You must write a program...

  • Please tell me whether my answers are correct or not. If not please tell me why...

    Please tell me whether my answers are correct or not. If not please tell me why and give me a guide to solving the problem correctly. Thanks! 3 Check Digits: ISBN In this problem, we'll look at a real-world applications of check-digits International Standard Book Numbers (ISBNS) are 10-digit codes (did2...dio) which are assigned by the publisher. These 10 digits contain information about the language, the publisher, and the number assigned to the book by the publisher. Additionally, the last...

  • I need it in c++ The U.S. Banking System The code assigned to a bank is...

    I need it in c++ The U.S. Banking System The code assigned to a bank is an eight digit number plus a ninth check digit. To check for validity, the first eight digits are assigned weights (left to right) of 7, 3, and 9 repetitively. Each digit is multiplied by its weight and the products summed. The resulting sum (mod 10) should equal the check digit. The assigning of weights insures that all single digit errors and most transposition errors...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • Please write c++ (windows) in simple way and show all the steps with the required output

    please write c++ (windows) in simple way and show all the steps with the required output Write a C++ program that simulates the operation of a simple online banking system The program starts by displaying its main menu as shown in Figure1 splay Account nformatson verity Your credit Card elect vour choice Figure 1 Main menu of the program The menu is composed of the following choices 1. When choice 1 is selected (Display Account information), the program should display...

  • Write a Java program, including comments, to compute statistics for how students did on an exam....

    Write a Java program, including comments, to compute statistics for how students did on an exam. The program should compute various things about a student and print it all out. Then it repeats the process for each new student until the entire set of data has been completed. (a) The program reads in and prints the ID number of a student [see step (g) below] and then the number of right answers and the number of wrong answers. (The total...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Programming in C. Name this program schwifty.c - This program reads a text file and makes...

    Programming in C. Name this program schwifty.c - This program reads a text file and makes it schwifty, but the user determines the schwiftiness. The user supplies the filename to schwift and a string containing a sequence of the following characters to determine the schwiftiness via command line arguments: L - Left shift each character in a word: hello --> elloh R - Right shift each character in a word: elloh --> hello I - Shift the letters' and digits'...

  • I wrote this code but there’s an issue with it : #include <iostream> #include <vector&...

    I wrote this code but there’s an issue with it : #include <iostream> #include <vector> #include <string> #include <fstream> using namespace std; class Borrower { private: string ID, name; public: Borrower() :ID("0"), name("no name yet") {} void setID(string nID); void setName(string nID); string getID(); string getName(); }; void Borrower::setID(string nID) { ID = nID; } void Borrower::setName(string nname) { name = nname; } string Borrower::getID() { return ID; } string Borrower::getName() { return name; } class Book { private: string...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT