Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java how to assign alphabet letter a score

int score = 0;
        int maxScore = 0;
        int count = 0;
        String[] strArr = s.split(" ");

        for (int i = 0; i < strArr.length; i++) {
            strArr[i] = strArr[i].toLowerCase();
            for (int j = 0; j < strArr[i].length(); j++) {
                if (j == 0) {
                    score = 0;
                }
                score += strArr[i].charAt(j) - 'a' + 1;
            }

            if (score > maxScore) {
                maxScore = score;
                count = i;
            }
        }
        return strArr[count];
Comment

java how to assign alphabet letter a score

'a' = 97;
'z' = 122;

'A' = 65;
'Z' = 90;

score += strArr[i].charAt(j) - 'a' + 1;
Comment

PREVIOUS NEXT
Code Example
Java :: set default messaging app android manifest 
Java :: who was the mother of thomas elva edison 
Java :: bipredicate in java 
Java :: comment initialiser un tableau de char en java 2d array 
Java :: do you have to implement all methods of an interface java 
Java :: do switch statement always run default java 
Java :: ggt euklidischer algorithmus java 
Java :: time in java 
Java :: get number value of an output to another script java 
Java :: how to change default size kafka 
Java :: dividing numbers using method 
Java :: randpm years java 
Java :: print java object inherited classes 
Java :: findby(xpath selenium java) 
Java :: 16 kare koku 4 in java 
Java :: Java Insert Elements to LinkedHashSet 
Java :: mock a service when the method returning void 
Java :: using automapper without dependency injection 
Java :: kotlin to java converter 
Java :: test function that call a function javascrip 
Java :: add SOSL to apex Example 
Java :: java active displays 
Java :: how to check if something exists in an sql column java 
Java :: URI/BEE problem no-1101 solution in Java 
Java :: plot vector field in java 
Java :: how to put all words from a file in an array java 
Java :: java destroy object 
Java :: Rotate array to left k cells python 
Java :: all GlideException#logRootCauses(String) for more detail Cause (1 of 1): class javax.net.ssl.SSLPeerUnverifiedException: Hostname 
Java :: code converter python to java 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =