Prompting user input and measuring string length

Report a typo

A user input is required for an application you are developing in Kotlin. The application should prompt the user to enter a string, display the entered string, and then output the length of the string that the user inputted. However, some parts of the code are missing. Can you fill the blanks in the code to make the program work as expected?

Fill in the gaps with the relevant elements
import java.util.

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    println("Enter a string:")
    val inputString = scanner.()
    println("You entered: $inputString")
    val  = inputString.length
    println("Length of your string is: $length")
}
lengthnextLineScanner
___

Create a free account to access the full topic