-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathISBN.java
29 lines (26 loc) · 878 Bytes
/
ISBN.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
import Package1.NumberManipulation;
import java.util.Scanner;
class InvalidInputException extends Exception {
InvalidInputException(String msg) {
super(msg);
}
}
public class ISBN {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String is = sc.nextLine();
try {
if (is.length() != 9) {
throw new InvalidInputException("ISBN must be exactly 9 digits");
} else {
NumberManipulation n = new NumberManipulation();
Integer i = Integer.parseInt(is);
n.extractDigits(i);
System.out.println("Last digit = " + n.findLastDigit());
System.out.println("New ISBN = " + is + n.findLastDigit());
}
} catch (Exception e) {
System.out.println(e);
}
}
}