# Java program: ISBN calculated by other 9 digits?

• 10-09-2010, 04:10 AM
SNFA
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;
• 10-09-2010, 04:26 AM
Fubarable
Your formula for the checksum seems off based on this Wikipedia article on ISBN: wiki/Isbn
• 10-09-2010, 04:42 AM
SNFA
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
• 10-09-2010, 05:13 AM
pbrockway2
The calculation looks OK - see the alternative calculation section of that wikipedia article.
• 10-09-2010, 05:15 AM
Fubarable
Quote:

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! :(
• 10-09-2010, 05:22 AM
pbrockway2
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.