Answers for "to uppercase 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

Browse Popular Code Answers by Language