validate isbn number java
Java
public boolean validateIsbn10( String isbn )
{
if ( isbn == null )
{
return false;
}
//remove any hyphens
isbn = isbn.replaceAll( "-", "" );
//must be a 10 digit ISBN
if ( isbn.length() != 10 )
{
return false;
}
try
{
int tot = 0;
for ( int i = 0; i < 9; i++ )
{
int digit = Integer.parseInt( isbn.substring( i, i + 1 ) );
tot += ((10 - i) * digit);
}
String checksum = Integer.toString( (11 - (tot % 11)) % 11 );
if ( "10".equals( checksum ) )
{
checksum = "X";
}
return checksum.equals( isbn.substring( 9 ) );
}
catch ( NumberFormatException nfe )
{
//to catch invalid ISBNs that have non-numeric characters in them
return false;
}
}
Also in Java:
- Title
- jtable get get row
- Category
- Java
- Title
- parsedouble java
- Category
- Java
- Title
- java string to int
- Category
- Java
- Title
- file with line numbers inserted java
- Category
- Java
- Title
- convert date to calendar java
- Category
- Java
- Title
- rgb to hex java
- Category
- Java
- Title
- queue implementation in java using arraylist
- Category
- Java
- Title
- java try catch
- Category
- Java
- Title
- java create folder
- Category
- Java
- Title
- find maven version
- Category
- Java
- Title
- java how to initialize an array
- Category
- Java
- Title
- java stream sort
- Category
- Java
- Title
- generic method lambda java
- Category
- Java
- Title
- how to open a webpage with java
- Category
- Java
- Title
- how make a final variable in java
- Category
- Java
- Title
- capitalize string java
- Category
- Java
- Title
- left shift in java
- Category
- Java
- Title
- how to remove all whitespace from string java
- Category
- Java
- Title
- expression régulière téléphone java
- Category
- Java
- Title
- java random char a-z
- Category
- Java
- Title
- set iteration java
- Category
- Java
- Title
- online money transfer andhra bank
- Category
- Java
- Title
- kotlin android intent pass data
- Category
- Java
- Title
- how to read to into a file in java
- Category
- Java
- Title
- android java shared preferences remove key
- Category
- Java
- Title
- partial view tiles spring
- Category
- Java
- Title
- array methods in java
- Category
- Java
- Title
- bukkit java get player count
- Category
- Java
- Title
- for loop in java stack overflow
- Category
- Java
- Title
- java fx display simple rectangle
- Category
- Java
- Title
- java resource file
- Category
- Java
- Title
- java 8 find min value in array
- Category
- Java
- Title
- import java.util.hashset
- Category
- Java
- Title
- java concatenate arrays
- Category
- Java
- Title
- butterfly pattern program in java
- Category
- Java
- Title
- how to append to a string in java
- Category
- Java
- Title
- java min function
- Category
- Java
- Title
- java 8 loop in map
- Category
- Java
- Title
- create jdbc connection in java
- Category
- Java
- Title
- how to add strings together
- Category
- Java
- Title
- java size of stack
- Category
- Java
- Title
- byte java
- Category
- Java
- Title
- declareing a variable in java
- Category
- Java
- Title
- java download file from url to string
- Category
- Java
- Title
- java string to lower case
- Category
- Java
- Title
- linux pyspark select java version
- Category
- Java
- Title
- error message pushes button down
- Category
- Java
- Title
- java list contains object with property
- Category
- Java
- Title
- java singleton
- Category
- Java
- Title
- is self divisor java
- Category
- Java
- Title
- initialize arraylist
- Category
- Java
- Title
- continue in java
- Category
- Java
- Title
- java scanner
- Category
- Java
- Title
- not equal java
- Category
- Java
- Title
- java code to get all leaf nodes of a xml file
- Category
- Java
- Title
- equls en java
- Category
- Java
- Title
- java get current date without time
- Category
- Java
- Title
- java arraylist in enum
- Category
- Java
- Title
- how to get witdth of window android
- Category
- Java
- Title
- how to cut a certion part from a string in java
- Category
- Java
- Title
- java string to double
- Category
- Java
- Title
- bufferedwriter doesn't write to file
- Category
- Java
- Title
- how to substring in java
- Category
- Java
- Title
- java create map
- Category
- Java
- Title
- how to get individual words from a string in java
- Category
- Java
- Title
- how to init an array with objects in java
- Category
- Java
- Title
- generate objects with for loop java
- Category
- Java
- Title
- how to remove spaces from an array in java
- Category
- Java
- Title
- java how to print a newline
- Category
- Java
- Title
- serialversionuid java
- Category
- Java
- Title
- abstraction in java
- Category
- Java
- Title
- open an existing excel file in java apache poi
- Category
- Java
- Title
- how to calculate exponential in java
- Category
- Java
- Title
- java pause program until key pressed
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- difference between java and javax
- Category
- Java
- Title
- main method java
- Category
- Java
- Title
- spigot cancel repeating task
- Category
- Java
- Title
- android java how to stop users fromgoing back too much
- Category
- Java
- Title
- java exceptions for catch
- Category
- Java
- Title
- java find duplicates in array
- Category
- Java
- Title
- boolean checkbox swing
- Category
- Java
- Title
- java create unmodifiable list
- Category
- Java
- Title
- creating a program about user asked to enter a number and enters 0 to stop, then calculates the sum of numbers entered, the average, the length of positive numbers and negative numbers entered by the user in java
- Category
- Java
- Title
- java get size of array
- Category
- Java
- Title
- android how to switch between activities
- Category
- Java
- Title
- java hashmap set value
- Category
- Java
- Title
- indexof java
- Category
- Java
- Title
- print a list java
- Category
- Java
- Title
- spigot get player from UUID
- Category
- Java
- Title
- iterate over map keys java
- Category
- Java
- Title
- biginteger in java
- Category
- Java
- Title
- remove first character from string
- Category
- Java
- Title
- big integer java
- Category
- Java
- Title
- java hashmap get value
- Category
- Java
- Title
- java foreach
- Category
- Java
- Title
- how to pass parameters to xsl file
- Category
- Java
- Title
- string equality in java
- Category
- Java
- Title
- java convert char to int
- Category
- Java
- Title
- java jagged array days and months
- Category
- Java