Solution to find All Check Digits in Java
ACES.txt File
100532P
300563X
500562Y
604532X
875300M
456231P
560340M
103562F
--------------------------------------------------------
PROGRAM
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashSet;
import java.util.Set;
public class CountChkDgt {
public static void main(String[] args) {
try {
Set hset=new HashSet();
BufferedReader br=new BufferedReader(new FileReader("./ACES.txt"));
String ss="";
String chk="";
while(true){
ss=br.readLine();
if(ss==null){
break;
}
chk=ss.substring(6, 7);
hset.add(chk);
}
for(String val: hset){
System.out.println(val);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
-----------------------------------------------------------
OUTPUT
F
P
M
Y
X