September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/Input-loop/Kotlin/input-loop.kotlin
Normal file
17
Task/Input-loop/Kotlin/input-loop.kotlin
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// version 1.1
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("Keep entering text or the word 'quit' to end the program:")
|
||||
val sc = Scanner(System.`in`)
|
||||
val words = mutableListOf<String>()
|
||||
while (true) {
|
||||
val input: String = sc.next()
|
||||
if (input.trim().toLowerCase() == "quit") {
|
||||
if (words.size > 0) println("\nYou entered the following words:\n${words.joinToString("\n")}")
|
||||
return
|
||||
}
|
||||
words.add(input)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue