Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: ISBN-10 enter 9 digit to find the 10th digit

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Thanked 0 Times in 0 Posts

    Default ISBN-10 enter 9 digit to find the 10th digit

    I have posted this yesterday and today did some modification to the code. What i need the code to do is have the user enter 9 digits all on one line and calculate in the formal giving to display the 9 digits that the user enter with the 10th number.

    import java.util.Scanner;

    public class Exercise3_9 {

    public static void main(String[] args) {
    Scanner input = new Scanner (System.in);

    while (true) {
    //Prompt the user to enter first 9 ISBN digits
    System.out.print("Enter the first 9 digits of the ISBN: ");
    int d1=(0);
    int d2=(1);
    int d3=(2);
    int d4=(3);
    int d5=(4);
    int d6=(5);
    int d7=(6);
    int d8=(7);
    int d9=(8);

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

    if (d10==10)
    System.out.println("The ISBN-10 number is " +d1+""+d2+""+d3+""+d4+""+d5+""+d6+""+d7+""+d8+""+d 9+"x");
    System.out.println("The ISBN-10 number is " +d1+""+d2+""+d3+""+d4+""+d5+""+d6+""+d7+""+d8+""+d 9+"1");


    The formal is : ((d1*1)+(d2*2)+(d3*3)+(d4*4)+(d5*5)+(d6*6)+(d7*7)+ (d8*8)+(d9*9)%11)

    Any help would be appreciated and sorry i didn't explain it that good last time.

    The way it is now it just repeat the output of this:
    Enter the first 9 digits of the ISBN:01234567891

    Thank you

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 698 Times in 680 Posts

    Default Re: ISBN-10 enter 9 digit to find the 10th digit

    How is this different than the previous post for which you've already been given some advice? If that advice was not useful, then explain why that is in the original post. Starting a new thread is confusing and unnecessary, especially if no new information is provided and the same problem is being worked.

Similar Threads

  1. How to convert a digit to words
    By Spanky_10 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 6th, 2013, 01:19 PM
  2. Digit counter
    By Rexshine in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 16th, 2013, 06:53 PM
  3. checking for digit while reading from a file
    By mia_tech in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: July 27th, 2012, 03:51 PM
  4. Timer digit
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 2nd, 2011, 08:07 PM
  5. Trying to crunch a date to a single digit
    By twitch09 in forum Java Theory & Questions
    Replies: 7
    Last Post: October 15th, 2010, 12:14 AM