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.

>> REGISTER NOW TO START POSTING

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

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

1. ## 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.
[highlight=java]

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");
else
System.out.println("The ISBN-10 number is " +d1+""+d2+""+d3+""+d4+""+d5+""+d6+""+d7+""+d8+""+d 9+"1");
System.out.println();
}
}
}

[highlight]

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. ## 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.