Posted by: Sourav | June 27, 2014

Check ISBN Number in Java


import java.util.*;
class project
{
    
    
    public static void main(String args[])
    {
        int sum=0;
       String stringnumber;
       char c;
       int number;
       int multiplier=10;
    Scanner in = new Scanner(System.in);
        
        System.out.println(“input the number”);
        
        stringnumber = (in.nextLine());
           
        int lengthnumber=stringnumber.length();
       
        for(int i=0;i<=(lengthnumber-1);i++)
            {
                number=Character.getNumericValue(stringnumber.charAt(i));
             
                   sum=sum+(number*multiplier);
                   //System.out.println(number);
                   multiplier=multiplier-1;
            }
            
            if((sum%11)==0)
            {
                
                System.out.println(“The given “+stringnumber+” is a valid ISBN number”);
                
            }
            else
            {
                 System.out.println(“The given “+stringnumber+” is not a valid ISBN number”);
            }
    }
    
    
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: