Question

Description: An ISBN-10 (International Standard Book Number) consists of 10 digits: didzdzdad5d6d7d8d9d1o. The last digit, di

0 0
Add a comment Improve this question Transcribed image text
Answer #1
// In java
import java.util.Scanner;

public class ISBN {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        //Initializing count to 1
        int count = 0;

        // Reading input
        System.out.print("Enter the first 9 digits of an ISBN-10 as a string: ");
        String s = scan.nextLine();

        //looping through each digit of the input
        for(int i = 1;i<10;i++){
            //Counting dx*x for digit dx
            count += (i*(s.charAt(i-1)-'0'));
        }
        // Calculating the reminder
        count = count % 11;

        // If count is less than 10 then appending reminder at the end
        if(count<10){
            s += count;
        }
        // If count is greater than or equals to 10 then appending X at the end
        else{
            s += "X";
        }

        // Printing the final value of s
        System.out.println("The ISBN-10 number is "+s);
    }
}

Output:

Enter the first 9 digits of an ISBN-10 as a string: 013601267 The ISBN-10 number is 0136012671 Process finished with exit cod

Enter the first 9 digits of an ISBN-10 as a string: 013031997 The ISBN-10 number is 013031997X Process finished with exit cod

Note Please comment below if you have any doubtsPlease up vote the solution if it helped. Thanks

Add a comment
Know the answer?
Add Answer to:
Description: An ISBN-10 (International Standard Book Number) consists of 10 digits: didzdzdad5d6d7d8d9d1o. The last digit, dio,...
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...

  • Write a program in Python that asks the user for the ISBN of the book in...

    Write a program in Python that asks the user for the ISBN of the book in the format xxx-x-xxx-xxxxx-x. To validate: Initialize a total to 0 Have the program remove the dashes so that only the 13 digits are left in the ISBN string for each index of the first 12 digits in the 13 digit ISBN string get the digit at the current index as an integer If the current index is an even number, add the digit to...

  • Introduction: Ten digit ISBN numbers are created so that the first nine digits are information digits...

    Introduction: Ten digit ISBN numbers are created so that the first nine digits are information digits and the last digit is a check digit. T his last number helps people notice and correct mistakes that might be made in recording the information digits. The same is true for thirteen digit ISBN numbers. Here is a ten digit ISBN number: 0-13-149498-8. The digit 0 indicates the book is written for English-speaking people. The number 13 and the number 149498 identify the...

  • In Python: Write a well-documented (commented) program that asks the user for a 9-digit integer, computes...

    In Python: Write a well-documented (commented) program that asks the user for a 9-digit integer, computes its checksum, and then prints the corresponding ISBN number. The International Standard Book Number (ISBN) is a 10-digit code that uniquely specifies a book. The rightmost digit is a checksum digit that can be uniquely determined from the other 9 digits, from the condition that d1 + 2d2 +3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith...

  • In Python Write a well-documented (commented) program that asks the user for a 9-digit integer, computes...

    In Python Write a well-documented (commented) program that asks the user for a 9-digit integer, computes its checksum, and then prints the corresponding ISBN number. The International Standard Book Number (ISBN) is a 10-digit code that uniquely specifies a book. The rightmost digit is a checksum digit that can be uniquely determined from the other 9 digits, from the condition that d1 + 2d2 +3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith...

  • 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

  • IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in...

    IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in it (first 9 digit in ISBN) Output: print out: "The correct checksum digit is:__. Now we have a legit ISBN: _____" Hint: just loop through 0-9, test every one with helper func1 to find out the one checksum that forms a legit ISBN with the correct ISBN in lis (10 numbers), call helper func2 to format it correctly. Then print the final result. '''...

  • write it in C++ please Exercise # 1 : The 10 digits are spelled out respectively...

    write it in C++ please Exercise # 1 : The 10 digits are spelled out respectively as follows: "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", and "Nine". Write a program that prompts the user to enter a one digit positive integer and prints the number of characters required to spell out the integer. For example, if the integer is 7 then it is spelled "Seven" which requires 5 characters. Sample input/ output: Enter a one digit number: 8...

  • Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from...

    Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 42339, the program should print “4 2 3 3 9.” (Hint: The number input is five digits long, dividing it by 10000 gives the leftmost digit. digit1 = number / 10000 ) b. determines...

  • With your partner, brainstorm a program that will ask the user for a number of digits...

    With your partner, brainstorm a program that will ask the user for a number of digits to be stored. The program should then create an array of that size and then prompt the user for numbers to fill each position in the array. When all of the positions are filled, display the contents of the array to the user. Create a new Project named FillArray and a new class in the default packaged named FillArray.java. You and your partner should...

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