package com.codemonkey
fun main(args:Array<String>){
var cadena: String = "MARIA"
var suma:Int=0
//Defino el mapa
val mapaNumero:HashMap<String,Int> = hashMapOf<String,Int>("A" to 1, "J" to 1, "S" to 1,"B" to 2, "K" to 2, "T" to 2
,"C" to 3, "L" to 3, "U" to 3, "D" to 4, "M" to 4, "V" to 4, "E" to 5, "N" to 5, "W" to 5
,"F" to 6, "O" to 6, "X" to 6,"G" to 7, "P" to 7,"Y" to 7,"H" to 8,"Q" to 8,"Z" to 8, "I" to 9
,"R" to 9, "Ñ" to 9);
for(i in 0 until cadena.length){
println("$i")
var car:Char= cadena.get(i)
var str:String= Character.toString(car)
var numero = mapaNumero.get(str)
suma += numero!!.toInt()
}
println("Cadena: $cadena")
println("Suma = $suma")
numerosMaestros(suma)
}
fun numerosMaestros(numero:Int):Unit{
when(numero){
11 -> println("$numero # maestro de la espiritualidad")
22 -> println("$numero # maestro del orden")
33 -> println("$numero # maestro del amor")
44 -> println("$numero # maestro del poder")
else ->{
println("$numero")
}
}
}
Calcular el valor numérico con Kotlin.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.