cambio de divisas
fun convertir(valor: Double, from: String, to: String): Double{ val euroAReal = 4.5 val euroAPeso = 25.0 val pesoAReal = 0.18 val euroAEs = 125.0 return when(from){ "euro" -> when(to){ "euro" -> valor "real" -> valor * euroAReal "peso" -> valor * euroAPeso "es" -> valor * euroAEs else -> 0.0 } "real" -> when(to){ "euro" -> valor / euroAReal "real" -> valor "peso" -> valor / pesoAReal "es" -> valor / euroAReal * euroAEs else -> 0.0 } "peso" -> when(to){ "euro" -> valor / euroAPeso "real" -> valor * pesoAReal "peso" ->