Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.util.*;
- public class checkDigit
- {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int value=0;
- int odd=0;
- int even=0;
- int checkDigit=0;
- System.out.println("Enter ISBN");
- String isbn=input.next();
- for (int x=0;(x<isbn.length()-1);x++){
- System.out.println(isbn.charAt(x));
- value=Character.getNumericValue(isbn.charAt(x));
- if (x%2==0){
- odd+=value;
- }
- else{
- even+=value;
- }
- }
- even=even*3;
- value=(odd+even)%10;
- if (value==0){
- checkDigit=value;
- }else{
- checkDigit=10-value;
- }
- System.out.println("ISBN check digit is..."+checkDigit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement