HW4.36

HW4.36

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter the ISBN: ");
         String isbn = input.nextLine();

         input.close();

         int numberOfISDN = Integer.parseInt(isbn.substring(0, 9));
         int sum = 0;

         for(int i = 9; i > 0; i--)
         {
             sum += (numberOfISDN % 10) * i;
             numberOfISDN /= 10;
         }

         if(sum % 11 == isbn.charAt(9))
             System.out.println("Valid ISBN");
         else if(sum % 11 == 10 && isbn.charAt(9) == 'X')
             System.out.println("Valid ISBN");
         else
             System.out.println("Invalid ISBN");
     }
 }
上一篇:01_安装redhat 7.1时常出现的问题


下一篇:JS兼容性问题(FF与IE)