-
Notifications
You must be signed in to change notification settings - Fork 0
/
YT41.java
50 lines (43 loc) · 1.05 KB
/
YT41.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.*;
class YT41
{
public static void main(String[] args)throws IOException
{
int n, d, r;
int c=0;
int x=10, s=0;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the number: ");
n=Integer.parseInt(br.readLine());
d=n;
while(n>0)
{
n=n/10;
c++;
}
//System.out.println(c);
if(c!=10)
{
System.out.println("Illegal ISBN");
}
else
{
while(d>0)
{
r=d%10;
s=s+(r*x);
x--;
d=d/10;
}
if(s%11==0)
{
System.out.println("ISBN Number");
}
else
{
System.out.println("Digits are 10 but not divisible by 11 hence, not an ISBN");
}
}
}
}