# Thread: Java program: ISBN calculated by other 9 digits?

1. Member
Join Date
Oct 2010
Posts
4
Rep Power
0

## Java program: ISBN calculated by other 9 digits?

Hi,

I need to create a program in which the 10th digit is the checksum. The program is to prompt the user to enter the first 9 digits and displays the 10 digit ISBN(including leading zeros). Last digit is denoted by an X. I have come up with this so far... But, I know I am still pretty far off. Could someone help me get this program going in the right direction.

Also thank you for all of those that were helping me with the JAVA pattern design. I am still working on it.

Thanks
Diana

Import java.util.scanner;

Public class ISBN {
public static void main(String [] args) {

Scanner input = new Scanner (System.in);
System.out.println ("Enter International Standard Book Number:");

int N = new Integer.parseInt(args [0]);

int sum = 0
for (int i = 2; i <=10; i++){

checksum = (d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11;

2. Member
Join Date
Oct 2010
Posts
4
Rep Power
0
Hi

I got this formula from the book. I have looked elsewhere but have also found other ways it has been done as well. So, I am not sure how this formula fits into the formula.

Diana

3. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
14
The calculation looks OK - see the alternative calculation section of that wikipedia article.

4. Originally Posted by pbrockway2
The calculation looks OK - see the alternative calculation section of that wikipedia article.
Thanks pbrockway and shame on me for overlooking that! :(

5. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
14
OP: The important thing is that *you* understand the formula you are using. Do you? Can you explain in words how you are going to go about calculating the check digit?

Then - and only then - start writing code. Every line of your code should be deliberate and should express a small step in the plan you have already decided on. Don't just slap down bits of code and hope that they will add up to something.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•