Answers for "to uppercase and lowercase kotlin"

2

caps to small in kotlin

class CapsToSmallAndSmallToCaps{
    init {
        val read = Scanner(System.`in`)
        val inputs:String = read.next()
        var ans: String = " "
        for (i in 0..inputs.lastIndex){
            if (inputs[i].toString() == inputs[i].uppercase(Locale.getDefault())){
                ans += inputs[i].lowercase(Locale.getDefault())
            }
            if (inputs[i].toString() == inputs[i].lowercase(Locale.getDefault())){
                ans += inputs[i].uppercase(Locale.getDefault())
            }

        }
        println(ans)
    }
}

fun main() {
    CapsToSmallAndSmallToCaps()
}
// kotlin
Posted by: Guest on May-31-2021

Code answers related to "to uppercase and lowercase kotlin"

Browse Popular Code Answers by Language