Create a program using Java's Scanner class for user input

Report a typo

You've been tasked with creating a basic program in Kotlin that asks the user to input a number, and then displays the number that was entered. The catch is that your input reader should utilize Java's Scanner class. You have started to write a basic skeleton for your program but there are some incomplete parts. Your task is to fill in the blanks in the code to make it function as described.

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

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    ("Please enter a number:")
    val number = scanner.()
    println("You entered: $number")
}
nextIntprintlnScanner
___

Create a free account to access the full topic