I'm having trouble making my program read in all of the integers on one line rather than having to enter each number and hit enter after each digit in the terminal window.
For example, the terminal window would read:
For the our text enter the first 9 digits: 013292373"
rather than
For the our text enter the first 9 digits: 0
1
2
3
... etc"
My code looks like this so far:
/**
* This program calculates the last number of a 10 digit ISBN number.
*/
import java.util.Scanner;
public class ISBNnum
{
public static void main(String[] args)
{
//Variables and Scanner
Scanner input = new Scanner(System.in);
int dOne;
int dTwo;
int dThree;
int dFour;
int dFive;
int dSix;
int dSeven;
int dEight;
int dNine;
int checksum;
//Input
System.out.print("For the our text enter the first 9 digits: ");
dOne = input.nextInt();
dTwo = input.nextInt();
dThree = input.nextInt();
dFour = input.nextInt();
dFive = input.nextInt();
dSix = input.nextInt();
dSeven = input.nextInt();
dEight = input.nextInt();
dNine = input.nextInt();
//Calculation
checksum = ((dOne * 1) + (dTwo * 2) + (dThree * 3) + (dFour * 4) + (dFive * 5) + (dSix * 6) +
(dSeven * 7) + (dEight * 8) + (dNine * 9)) % 11;
//Output
if (checksum == 10)
{
System.out.print("The whole ISBN is "+dOne+dTwo+dThree+dFour+dFive+dSix+dSeven+dEight+
dNine+"X");
}
else if (checksum < 10)
{
System.out.println("The whole ISBN is " + dOne + dTwo + dThree + dFour + dFive + dSix +
dSeven + dEight + dNine + " - " + checksum);
}
}
}
Thanks for your help guys!