/home/caleb/NetBeansProjects/ADSV Java/MP2_CalebFontenot/src/main/java/com/calebfontenot/mp2_calebfontenot/CheckIBSN_10.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.mp2_calebfontenot;
import java.util.*;
@author
public class CheckIBSN_10 {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, inputISBN, outputISBN;
boolean debug = true;
System.out.print("Enter the first 9 digits of an ISBN as an integer: ");
inputISBN = input.nextInt();
digit1 = inputISBN / 100000000 % 10;
digit2 = inputISBN / 10000000 % 10;
digit3 = inputISBN / 1000000 % 10;
digit4 = inputISBN / 100000 % 10;
digit5 = inputISBN / 10000 % 10;
digit6 = inputISBN / 1000 % 10;
digit7 = inputISBN / 100 % 10;
digit8 = inputISBN / 10 % 10;
digit9 = inputISBN / 1 % 10;
if (debug == true)
{
System.out.println("inputISBN: " + inputISBN);
System.out.println("ISBN split into 9 digits: " + (digit1) + " " + (digit2) + " " + (digit3) + " " + (digit4) + " " + (digit5) + " " + (digit6) + " " + (digit7) + " " + (digit8) + " " + (digit9));
}
outputISBN = ((digit1 * 1) + (digit2 * 2) + (digit3 * 3) + (digit4 * 4) + (digit5 * 5) + (digit6 * 6) + (digit7 * 7) + (digit8 * 8) + (digit9 * 9)) % 11;
if (outputISBN == 10)
{
System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + "X");
}
else
{
System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + outputISBN);
}
}
}