In: Computer Science
***This is done with Java programming***
Write a well-documented (commented) program, “ISBN,” that takes a 9-digit integer as a command-line argument, computes the checksum, and prints the ISBN number.
You should use Java’s String data type to implement it. 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 digit from the right).
The checksum digit d1 can be any value from 0 to 10. The ISBN convention is to use the character X to denote 10. The checksum digit corresponding to 032149805 is 4 since 4 is the only value of x between 0 and 10 (both inclusive), for which 10·0 + 9·3 + 8·2 + 7·1 + 6·4 + 5·9 +4·8 +3·0 + 2·5 + 1·x is a multiple of 11.
Sample runs would be as follows.
>java ISBN 013376940
The ISBN number would be 0133769402
>java ISBN 013380780
The ISBN number would be 0133807800
***This is done with Java programming***
public class ISBN1 {
    public static void main(String[] args) {
        if(args.length==1){
            //Initializing count to 1
            int count = 0;
            // Reading input
            String s = args[0];
            //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 number would be "+s);
        }
    }
}