Results 1 to 6 of 6
  1. #1
    SNFA is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    SNFA is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default

    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

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    The calculation looks OK - see the alternative calculation section of that wikipedia article.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

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

  6. #6
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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.

Similar Threads

  1. Digits of an integer.
    By Allgorythm in forum New To Java
    Replies: 8
    Last Post: 01-01-2010, 02:34 AM
  2. Replies: 3
    Last Post: 08-19-2009, 03:54 AM
  3. ISBN Checker
    By blobs86 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 11:07 PM
  4. Formatting isbn number with Math.random()
    By dns77x7 in forum New To Java
    Replies: 11
    Last Post: 09-21-2008, 06:02 PM

Posting Permissions

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