Предполагается, что следующий код преобразует буквы в числа и выдает сумму, но игнорирует любые буквы в верхнем регистре.
Пример:
Ввод abcde должен возвращать 15. Ввод abCde должен возвращать 12.
Любая помощь приветствуется.
static int strScore(String str[], String s, int n) {
int score = 0, index=0;
for (int i = 0; i < n; i++) {
if (str == s) {
for (int j = 0; j < s.length(); j++)
score += s.charAt(j) - 'a' + 1;
index = i + 1;
break;
}
}
score = score * index;
return score;
}
public static void main(String[] args) {
String str[] = { "abcde" };
String s = "abcde";
int n = str.length;
int score = strScore(str, s, n);
System.out.println( score);
}
Подробнее здесь: https://stackoverflow.com/questions/610 ... -lowercase