package codewars.kyu7;

/**
 * @name Fix string case
 * @rank 7
 * @id 5b180e9fedaa564a7000009a
 * @url https://www.codewars.com/kata/5b180e9fedaa564a7000009a
 */
public class FixStringCase {

    public static String solve(final String str) {
        int upperCount = 0;
        int lowerCount = 0;
        for (int i = 0; i < str.length(); i++) {
            if (Character.isUpperCase(str.charAt(i))) {
                upperCount++;
            } else {
                lowerCount++;
            }
        }
        return (lowerCount >= upperCount) ? str.toLowerCase() : str.toUpperCase();
    }
}
