Java Program for ISBN Number2 min read

In this tutorial, we will learn about the ISBN (International Standard Book Number) and write a program to check for the ISBN Number in Java

ISBN number program in java.

ISBN is a 10-digit unique number that is is carried by almost each and every book. It is used to identify the book uniquely. With the help of ISBN, we can easily find a book. The ISBN is legal if 1*digit1 + 2*digit2 + 3*digit3 + 4*digit4 + 5*digit5 + 6*digit6 + 7*digit7 + 8*digit8 + 9*digit9 + 10*digit10 is divisible by 11.

The first nine digits of the ISBN number are used to represent the Title, Publisher, and Group of the book, and the last digit is used for checking whether ISBN is correct or not.

Example:

Let us consider a number: 1259060977
Check:
Sum = 1*10 + 2*9 + 5*8 + 9*7 + 0*6 + 6*5 + 0*4 + 9*3 + 7*2 + 7*1 = 209
Now divide the sum by 11 and see if the remainder obtained is zero or not.
rem = 209%11 = 0
Since, rem = 0, therefore 1259060977 is a legal ISBN number.


Steps to write Program for ISBN number Java

  • First, take a 10-digit number input from the user.
  • The second step is to check if the entered number is 10-digits or not because a number cannot be ISBN if it is not a 10-digit number. If it is not a 10-digit number then we will display an invalid message otherwise follow the steps below.
  • For the sum, we need to multiply each digit by 1 to 10 from left to right.
  • Lastly, divide the sum and check if the remainder is zero or not, if it is zero then the entered number is an ISBN number else it is not.

Now let us implement the above logic to check whether the number is an ISBN or not in java.


Java Program to check for ISBN Number

Output: After execution following result will be displayed.

//Run: 1
Enter 10-digit ISBN number: 1259060977
1259060977 is a Legal ISBN Number

//Run: 2
Enter 10-digit ISBN number: 8417652579
8417562579 is an Illegal ISBN Number

You may create a separate user define function where you can pass the entered number and do the necessary calculation and at the end return the result to the main function. This is how you calculate the ISBN number java.


MORE

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …
Read More

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read More

Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read More

Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read More

Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read More

Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read More