Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 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