Printing each word in a new line

Report a typo

Write a program that reads five words from the standard input and outputs each word on a new line.

Words can be ordered differently in the input stream.

To solve the problem, use Scanner .

Sample Input 1:

This course
teaches you Kotlin

Sample Output 1:

This
course
teaches
you
Kotlin

Sample Input 2:

one two three four five

Sample Output 2:

one
two
three
four
five
Write a program in Kotlin
import java.util.Scanner

fun main() {
val scanner = Scanner(System.`in`)
// put your code here
}
___

Create a free account to access the full topic