plduhoux
2/23/2018 - 1:30 AM

properNounCorrection

String properNounCorrection(String noun) {
    String res = "";
    for (int i = 0; i < noun.length(); i++) {
        if (i == 0) {
            if (noun.charAt(i) >= 97) res += (char)(noun.charAt(i) - 97 + 65);
            else res += noun.charAt(i);
        } else {
            if (noun.charAt(i) >= 65 && noun.charAt(i) <= 91) res += (char)(noun.charAt(i) - 65 + 97);
            else res += noun.charAt(i);
        }
    }
    return res;
}