Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import java.util.Scanner;
public class SEDOL{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String sedol = sc.next();
System.out.println(sedol + getSedolCheckDigit(sedol));
}
}
private static final int[] mult = {1, 3, 1, 7, 3, 9};
public static int getSedolCheckDigit(String str){
if(!validateSedol(str)){
System.err.println("SEDOL strings must contain six characters with no vowels.");
return -1;
}
str = str.toUpperCase();
int total = 0;
for(int i = 0;i < 6; i++){
char s = str.charAt(i);
total += Character.digit(s, 36) * mult[i];
}
return (10 - (total % 10)) % 10;
}
public static boolean validateSedol(String str){
return (str.length() == 6) && !str.toUpperCase().matches(".*?[AEIOU].*?");
}
}