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

• September 28th, 2013, 02:46 PM
cldance5678
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
• September 28th, 2013, 02:52 PM
GregBrannon
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.