COMP2396
Loading...
Searching...
No Matches
Question1.java
Go to the documentation of this file.
1
package
tutorial2;
2
import
java.io.*;
3
4
public
class
Question1
{
5
public
static
void
main
(String[] args)
throws
IOException {
6
BufferedReader br =
new
BufferedReader(
new
InputStreamReader(System.in));
7
String
id
= br.readLine();
8
9
// note: the tutorial solution didn't '+ 1' to the first character
10
int
sum = (
id
.charAt(0) -
'A'
+ 1) * 8;
11
12
for
(
int
i = 1; i <= 6; i++) {
13
int
value = (
id
.charAt(i) >=
'A'
&&
id
.charAt(i) <=
'Z'
) ?
id
.charAt(i) -
'A'
+ 1 :
id
.charAt(i) -
'0'
;
14
sum += (8 - i) * value;
15
}
16
17
int
check = 11 - (sum % 11);
18
if
(check == 10) {
19
System.out.println(
'A'
);
20
}
else
if
(check == 11) {
21
System.out.println(
'0'
);
22
}
else
{
23
System.out.println(check);
24
}
25
}
26
}
tutorial2.Question1
Definition
Question1.java:4
tutorial2.Question1.main
static void main(String[] args)
Definition
Question1.java:5
tutorial2
Question1.java
Generated on Sat Dec 7 2024 17:10:09 for COMP2396 by
1.12.0