KT
kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Actually input should work with the following.
import java.util.Scanner
val scan = Scanner(System.`in`)
var text = scan.nextLine()
Unfortunately it isn't working here. You can try from another app "Dcoder".
*/
fun main(args: Array<String>) {
// Input readLine works only when users are in beta version. Alternatively use the next commented variable.
var text = readLine()!!
// Uncomment below variable↓
// var text = "This Is A SolOLEarn App"
// Loops through the text.
for(i in 0..text.length-1){
// "when" replaces "switch" operator in C-languages and Java. When "when" matches its argument against all branches sequentially until some branch condition is satisfied.
when(text[i]){
// Two or more branch conditions can combine with a comma.
'a','A' -> print(4)
'e','E' -> print(3)
'i','I' -> print(1)
'o','O' -> print(0)
'u','U' -> print(7)
// Otherwise it prints if none of other branch conditions are satisfied.
else -> print(text[i])
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run