Answers for "find how may caps in a word in kotlin kotlin"

1

find how may caps in a word in kotlin kotlin

import java.util.*

class FindHowMayCapsInAWord {
    init {
        print("Enter THe Word : ")
        val read = Scanner(System.`in`)
        val inputs:String = read.next()
        var ans: Int = 0
        for (i in 0..inputs.lastIndex) {
            if (inputs[i].toString() == inputs[i].uppercase(Locale.getDefault())) {
                ans += 1
            }
        }
        println("There are $ans Cap letters")
    }
}
 
 
 // kotlin
Posted by: Guest on May-31-2021

Browse Popular Code Answers by Language